SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2001
    Location
    The Netherlands
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a login page, a main page with a form on it and a logout page. I want to (using only sessions in php) have it so that if you're logged on and don't do anything for 5 minutes and then try and submit the form it doesn'tget submitted and you get logged out to the logout page.

    I have the following on my pages and it doesn't work. Can anyone see what I'm doing wrong?

    Login page
    -------------------
    if(isset($sessionid))
    {
    session_id($sessionid);
    session_start();
    session_unregister($submittime);
    session_destroy();
    }

    session_start();

    session_register("submittime");

    $user_session_id = session_id();

    //I then set $submittime = time(); when the submit on the login page is used...


    Main page
    -----------------------------
    if(isset($sessionid))
    {
    session_id($sessionid);
    }
    session_start();

    $submittime = $HTTP_SESSION_VARS["submittime"];

    //and where the submit button is submitting the form I have

    if ((time() - $submittime) > 15)
    {
    header ("Location: .....logout.php");
    exit;
    }
    else
    {
    $submittime = time();
    }

    Logout page
    ---------------

    if(isset($sessionid))
    {
    session_id($sessionid);
    session_start();
    session_unregister($submittime);
    }
    else
    {
    session_start();
    }

    session_destroy();

  2. #2
    SitePoint Addict
    Join Date
    Nov 2000
    Location
    London, UK
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If nothing else, then on your main page change the
    PHP Code:
    if( (time()-$sumbittime)>15 ){
    blah blah

    to:
    PHP Code:
    if( (time()-$submittime)>300){
    blah blah

    since time() is in seconds, you want 300 which would give you five mins ( I think ... it pretty late at nite, so I not sure )

    ... what's the world coming to?

  3. #3
    SitePoint Member
    Join Date
    Feb 2001
    Location
    The Netherlands
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    True - I was testing it with 15 secs first...thanks though

  4. #4
    SitePoint Addict
    Join Date
    Nov 2000
    Location
    London, UK
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe .. sorry 'bout that

    ... what's the world coming to?


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
  •