iPhoneJavaDev
iPhoneJavaDev

Reputation: 825

Cannot destroy php session in chrome

When I signout, I call the following to destroy the session. It works in other browsers but in Chrome, the session is still there.

session_unset();
session_destroy();

Please help if I there's a special way to do it in Chrome and other browsers.

Upvotes: 1

Views: 2228

Answers (2)

mister martin
mister martin

Reputation: 6252

When in doubt, check the manual:

<?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();

Upvotes: 1

Michał G
Michał G

Reputation: 2292

session is stored on server - it have nothing to do with browser ( in browser could be only cookie with session id or something like )

Upvotes: 0

Related Questions