#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    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.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    13
    See if changing the session life helps:

    http://www.php.net/manual/en/session...ookie-lifetime
  4. #3
  5. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,247
    Rep Power
    9400
    When you do requests to the PHP are you including the session ID?
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    13
    Originally Posted by requinix
    When you do requests to the PHP are you including the session ID?
    Yeah that might be a good way to ensure that the phpsessid is sent.

    Does your flash application ever redirect the user around? Make sure the domain stays the same (e.g. if the user is on domain.com don't send them to www.domain.com)

IMN logo majestic logo threadwatch logo seochat tools logo