I am developing a game for android which uses PHP servlets to access a database. They are multiple PHP files. My android application asks the PHP files for data stored in the database. I'm trying to implement some kind of session control for my PHP servlets. In the PHP referent to the user login(login.php), I added
session_start();
// set time-out period (in seconds)
$inactive = 1800;
// check to see if $_SESSION["timeout"] is set
if (isset($_SESSION["timeout"])) {
// calculate the session's "time to live"
$sessionTTL = time() - $_SESSION["timeout"];
if ($sessionTTL > $inactive) {
session_destroy();
echo "fazer_login_novamente";
}
}
$_SESSION["timeout"] = time();
while($row=mysql_fetch_assoc($result)){
$json[]=$row;
}
Right after the user succeeds on logging in. Now, after logging in, the application asks for words stored in the database by connecting to another PHP file. This new php (words.php) checks if the user has already started a session or if it's some king of hijacking through the checkSession PHP function of this link:http://php.net/manual/pt_BR/function.session-regenerate-id.php
BUt it seems the user always gets the exception "no session started" when connecting to words.php.
What am I doing wrong? Can you help me?
EDIT: here's a link to words.php: https://www.dropbox.com/s/23em2h3l3hj1via/login.php?dl=0
EDit: here's a link to login.php: https://www.dropbox.com/s/1hp6udivy8whvl8/words.php?dl=0