graham23s Posted December 3, 2008 Share Posted December 3, 2008 Hi Guys, My login system uses sessions toi store the users id and username (Just use id for getting info from mysql etc), i'm trying to figure out, if they tick the rememeber me button on the login form, how i remember them lol i set the cookie fine but when testing the page is never remembered: code: <?php ob_start(); session_start(); if($_SESSION['logged_in'] != 'yes') { header("Location: login.php"); } // CHECK TO SEE IF THE REMEMBER ME WAS TICKED if (isset($_COOKIE['customers_cookie_id'])) { // VARS $varCookie = $_COOKIE['customers_cookie_id']; } // VARS $var_loggedinuserid = $_SESSION['id']; $var_loggedinuserfirstname = $_SESSION['first_name']; ?> thats's the code thats at the top of my protected pages! if i echo out $varCookie i get 6 which is my ID! so i... 1) tick the remember me button 2) set a cookie if its ticked (with the users id) then i'm stuped lol if im using sessions how could i use cookies kinda thing any advice would be great cheers Graham Link to comment https://forums.phpfreaks.com/topic/135417-sessions-and-cookies-in-login/ Share on other sites More sharing options...
gevans Posted December 3, 2008 Share Posted December 3, 2008 You want to check the cookie before the sessions are checked. Store for example the user id in the cookie, then when they come back to the site check for the cookie, if the cookie is set run a login script that uses that id. That will login the user and make the session check return true Link to comment https://forums.phpfreaks.com/topic/135417-sessions-and-cookies-in-login/#findComment-705435 Share on other sites More sharing options...
graham23s Posted December 3, 2008 Author Share Posted December 3, 2008 got ya! thanks for that mate Link to comment https://forums.phpfreaks.com/topic/135417-sessions-and-cookies-in-login/#findComment-705496 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.