tomm098 Posted May 4, 2010 Share Posted May 4, 2010 Hey, I have this $_SESSION code, across all my pages, however I was wondering how to make it so the browser remembers the user, and they do not have to login everytime they come back to my website. Just like how you are always logged into this site. Here is my PHP code: <?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "../index.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> Link to comment https://forums.phpfreaks.com/topic/200631-how-do-i-stop-user-session-from-logging-out/ Share on other sites More sharing options...
trq Posted May 4, 2010 Share Posted May 4, 2010 You'll need to use cookies. Link to comment https://forums.phpfreaks.com/topic/200631-how-do-i-stop-user-session-from-logging-out/#findComment-1052825 Share on other sites More sharing options...
tomm098 Posted May 4, 2010 Author Share Posted May 4, 2010 Do you know how I would go about doing that? I'm not sure where to even start using cookies? Link to comment https://forums.phpfreaks.com/topic/200631-how-do-i-stop-user-session-from-logging-out/#findComment-1052829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.