
November 25th, 2012, 08:27 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 1
Time spent in forums: 10 m 54 sec
Reputation Power: 0
|
|
|
PHP-General - PHP Session Issue
Hey guys,
I'm new to this forum and I have a question about php sessions. Currently I'm designing a game using Actionscript 3 and PHP. It's essentially a browser-based MMO in which all the backend stuff is handled by PHP. The problem is, my PHP session will terminate at seemingly random times while playing, which will cause the game to stop working. Unfortunately since the entire webpage is covered by the SWF, I have no way of knowing when the session has terminated, except that the game stops working.
Currently this is the code I have in every PHP page on my site:
Code:
session_set_cookie_params(0); ini_set('session.gc_maxlifetime', 0); ini_set('session.cookie_lifetime', 0);
session_start();
session_cache_expire(20);
$inactive = 1200;
if(isset($_SESSION['timeout']) )
{ $session_life = time() - $_SESSION['timeout']; if($session_life > $inactive){ session_destroy(); header("Location: index.php"); } }
$_SESSION['timeout'] = time();
As I said, my session is still terminated at unpredictable times and at no point has the code sent me back to the index page. Any help that could be offered is greatly appreciated. Thanks.
|