SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Session expiring problem

    I seem to have some wierd problems with my sessions stating there expired when really they click another link and its fine. In every script I include first the session start, and then a config file which connects to the db and then a file which contains the 2nd php code as the first line.

    PHP Code:
    function getUser($theid) {
     
    $udata=mysql_query("select * from userdb where id='$theid' LIMIT 1");
     if (
    mysql_num_rows($udata)==0) {
      echo 
    "You have been auto logged out due to inactivity, please login again.";
      exit;
     }
     
    $playerinfo mysql_fetch_array($udata);
     return 
    $playerinfo;

    I call that function on the included file with this:

    PHP Code:
    $playerinfo getUser($_SESSION["id"]); 
    The auto logged out message is strange because it only shows up on certain pages. I checked those pages and everything is the exact same as the ones they state as working. It has been tested in FireFox, IE, Opera, all with the same effects.

    Whats even more strange to me is that when they get this message they just click another link that requires the sesssions to work and it loads just fine as if nothing had happened. So in not sure if theres something else I can try, or maybe load the sessions from the database instead of file to file. Also everytime I have a popup that loads the sessions it has the same effects of expiring.

  2. #2
    From downunder but sure 2 rise Hazardous's Avatar
    Join Date
    Aug 2003
    Location
    New Zealand
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sounds sort of wierd
    have you registed the variable
    PHP Code:
    session_register("id"); 
    Hazardous
    My Blog

  3. #3
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes once they login the ID is set and used on every page after that. Its just 2 or 3 pages that are giving the problems. I have a news system where links and text are placed into the database. Which are then generated on the page which is what they are clicking. The links which are giving problems I just noticed are a bit different then the others.

    <a href="http://example.com/scripts/lookup.php?lookup=135">Test</a> defeated you

    They look like that in the database. The ones that worked before were just direct links such as:

    <a href="mail.php?lookup=135">Test</a> mailed you

    Could it be the full url that is having problems?

  4. #4
    SitePoint Zealot
    Join Date
    Oct 2005
    Location
    Los Angeles
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you started the session:
    session_start();
    ?
    A lot of people keep forgetting about this

  5. #5
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup I have

    <?php session_start();

    on every page including the popups that have error messages in question.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •