Results 1 to 4 of 4

Thread: php session

  1. #1
    Join Date
    Nov 2009
    Posts
    1

    Unanswered: php session

    hi buddies,

    i wanted help on a session that i have created a page and i wanted it to expire the moment u leave the page with the session attached.

    Can anyone help me out... thanks
    Last edited by gidmakus; 11-03-09 at 13:14. Reason: the way i addressed

  2. #2
    Join Date
    Nov 2009
    Posts
    9
    How about urging user to logout before he closes the page?

  3. #3
    Join Date
    Nov 2008
    Posts
    117
    Hi try this, make a logout button and add this coding,
    Code:
    <?php
    // Initialize the session.
    // If you are using session_name("something"), don't forget it now!
    session_start();
    
    // Unset all of the session variables.
    $_SESSION = array();
    
    // If it's desired to kill the session, also delete the session cookie.
    // Note: This will destroy the session, and not just the session data!
    if (ini_get("session.use_cookies")) {
        $params = session_get_cookie_params();
        setcookie(session_name(), '', time() - 42000,
            $params["path"], $params["domain"],
            $params["secure"], $params["httponly"]
        );
    }
    
    // Finally, destroy the session.
    session_destroy();
    ?>

  4. #4
    Join Date
    Mar 2010
    Posts
    8
    the logic is that it is to set session expire till 00, also a code for deleting cookies will be much helpful to use bcoz
    these have almost every info you send to the web. so deleting them is also a very good idea.
    Last edited by nevin; 03-24-10 at 04:31.

Tags for this Thread

Posting Permissions

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