Problem with session

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everyone,

I was wondering if anyone can help me with solvoing this problem.  For some reason, the session_is_registered() function does not seem to see the session when the page is reloaded.  The pages following through all work, except if the user comes back to the index page.  At that point the session_ID is incremented.  

If at the index page, the reload button is continuously pressed, even-though the browser has not been closed, session_is_registered() function fails to find the session and starts a whole new session.

I would sincerely appreciate it if anyone may be able to help me out with this.

Thanks,
-AM


p.s. The code I'm talking about is below:

<?
    session_start();
    
    $user_ip    = getenv('REMOTE_ADDR');
    $user_host  = getenv('REMOTE_HOST');
    $user_agent = getenv('HTTP_USER_AGENT');
    
    if (!session_is_registered("session_id")) {
        @ $db_conn = mysql_pconnect("pals.wright.edu", "pals_user", "bytes");
        if (!$db_conn) {
            $message = $message . "Error: Could not connect to database pals.<br><br>";
        }
   
        mysql_select_db("pals");
        $query = "INSERT INTO session (begdateTime, ip_address, platform) VALUES
                                      (now(), '".$user_ip."', '".$user_agent."')";
        $result = mysql_query($query);
        $session_id = mysql_insert_id();
        
        if ($result) {
             $status = session_register("session_id");        
             $isit = session_is_registered("session_id");
             $message = $message . "<br><br>Your session ID is: $session_id<br><br>";
        }
        else {
             $message = $message . "Error: Failed to register session id into database.<br><br>";
        }
    }
    else {
        $message = $message . "You already have a session id: $session_id<br><br>"; 
    }
?>

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux