I’m write a Android App which based LAMP.
There is a login function in the app.
All of operation functions are perfect. But,
Why Linux makes session files everytimes
only when I connect on phone which utilizing httpURLConnection ???
When I connect web page without login by WebBrowser(Chrome),
The Linux makes Session file it’s empty <—(A)
And then, I connect web page with login by WebBrowser(Chrome) too,
The Linux makes Session file which appended in the (A) session file.
so. result. If I use webbrowser, linux makes session file, only 1.
But!
When I connect on the phone(app),
Linux makes session file everytimes If I login,
It means
App login -> (Linux makes session)
backpress -> App Login -> (Linux makes session)
backpress -> App Login -> (Linux makes session)
** I checked PHPSESSID in Logcat, and Cache SQL, utilizing cookie sync manager
Android HttpURLConnection Header Part Source
URL urlLogin = new URL(url);
HttpURLConnection httpConn = (HttpURLConnection) urlLogin.openConnection();
httpConn.setDefaultUseCaches(true);
httpConn.setDoInput(true);
httpConn.setDoOutput(true);
httpConn.setUseCaches(true);
httpConn.setInstanceFollowRedirects(false);
httpConn.setRequestMethod("POST");
httpConn.setRequestProperty("content-type", "application/x-www-form-urlencoded;charset=utf-8");
httpConn.setRequestProperty("Connection", "keep-alive");
PHP Login server part
<?php
session_start();
require_once "dbconn.php";
require_once "check.php";
require_once "process.php";
$email = $_POST['email'];
$pw = $_POST['pw'];
$process = new Process($_POST);
if ($process->checkLogin()) { //Check Login matches
$_SESSION['email'] = $email;
$_SESSION['pw'] = $pw;
$_SESSION['logged'] = true;
$errcode = 100;
}
Assuming “session file” == “session cookie”, perhaps you have not enabled cookie management for
HttpUrlConnection. As is described in the documentation, you need to useCookieHandlerandCookieManagerfor this: