开发者

Session destroy

In my working platform i endedup with a session_destroy problem

function logout()
{

 $_SESSION['id'] = '';
 session_destroy();

}

Here i unset the session id variable with a null value and uses the session_destroy() function to destroy the session.

But the problem is that after logged out from my account, when i press the back button of the browser it shows the status as logged in. Even i can browse through the profile and lin开发者_StackOverflow社区ks of my account.

Thank you


you must unset session as well as destroy session to remove it completely from your system.

you can do it with php functions..

session_unset(); or you can use unset($_SESSION);
session_destroy();


it think you should try using session_unset()

In order to kill the session altogether, like to log the user out, the session id must also be unset.

If a cookie is used to propagate the session id (default behavior), then the session cookie must be deleted. setcookie() may be used for that

<?php
session_start();

$sessionName = session_name();
$sessionCookie = session_get_cookie_params();

session_unset();
session_destroy();

setcookie($sessionName, false, $sessionCookie['lifetime'], $sessionCookie['path'],    $sessionCookie['domain'], $sessionCookie['secure']);
?>


Try this:

unset($_SESSION);
session_destroy();
session_regenerate_id();


Instead of rolling your own session code and possibly missing something, try using Zend_Session:

http://framework.zend.com/manual/en/zend.session.html

The constructor of Zend_Session_Namespace will automatically call session_start(), and likewise the Zend_Session::destroy() method will clean everything up in a logout script. Most of the work has already been done for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜