Error while destroying session in PHP -


i having problem in session handling in php(version 5.2.10). using below mentioned functions login, logout , validating sessions.

 login() {     session_set_cookie_params(0);     session_start();     session_regenerate_id(true);     $_session['user_id'] }  validate_session() {     session_set_cookie_params(0);     session_start();     if (isset($_session['user_id']) === false) {         session_destroy();         logout();         header("location: login_page");     } }  logout() {     session_set_cookie_params(0);     session_start();     $_session = array();     setcookie(session_name(), '', time() - 3600, '/');     session_destroy(); } 

every page first makes call validate_session() function. if session invalid redirects login page. login() function used creating session user. when user clicks logout, logout() function called destroy session.

the problem is: randomly logout() function throws warning:
warning: session_destroy(): session object destruction failed

i getting warning infrequently. out of 20-30 calls logout, once. thoughts?

i developing on windows xp machine.

update: sessions stored in file-system.
path: c:\windows\temp

is logout() called elsewhere in validate_session() ? if not, problem might call session_destroy() before logout()

you try this:

validate_session() {     session_set_cookie_params(0);     session_start();     if ( !isset( $_session['user_id'] ) ) {         logout();         header("location: login_page");     } }  logout() {     $_session = array();     setcookie(session_name(), '', time() - 3600, '/');     session_destroy(); } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -