php - Destroy the Session File after logout -


i have code login storing following in session variables:

if($do == "login") {     session_start();     $_session["valid"] = true;     $_session["studentuniqueid"] = $user_row['studentuniqueid'];     $_session["loginname"] = $loginname;     $_session["timeout"] = $now; }  

session file looks likethis:

valid|b:1;studentuniqueid|s:5:"10001";loginname|s:13:"abc@gmail.com";timeout|s:19:"2015-07-01 18:26:32";

also code logout destroying user session:

    if($do == "logout") {                 session_start();                 $_session = array();                 session_unset();                 session_destroy();             } 

after logout session files contains:

valid|b:0;

even have used session_destroy(), after logout session file exist valid|b:0; on servers temp directory , size of temp directory increases considerably.

i want rid of these files after session_destroy()/logout not way now.

is way going wrong code.

edit 2 :(erasing complete session data, can use below code)

ini_set('session.gc_max_lifetime', 0); ini_set('session.gc_probability', 1); ini_set('session.gc_divisor', 1); 

edit 1 (original) : try php manual

<?php // initialize session. // if using session_name("something"), don't forget now! session_start();  // unset of session variables. $_session = array();  // if it's desired kill session, delete session cookie. // note: destroy session, , not 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"]     ); }  // use ini_set('session.gc_max_lifetime', 0); ini_set('session.gc_probability', 1); ini_set('session.gc_divisor', 1);  // finally, destroy session. session_destroy(); ?> 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -