searls03 Posted June 8, 2011 Share Posted June 8, 2011 what are the different ways to store login data on the site(sessions, cookies, etc.)? which is the best? what would I use to make it so that if the page is left and then revisited the login data is still there or like if you click on login, it will redirect you to the main member page? does this make sense? Quote Link to comment Share on other sites More sharing options...
fugix Posted June 8, 2011 Share Posted June 8, 2011 what would I use to make it so that if the page is left and then revisited the login data is still there or like if you click on login, it will redirect you to the main member page? i will address these questions, to make it so the user still has there data saved for when they come back to your website, you can set a cookie using the setcookie()with user data stored inside and set for however long you want the user to stay logged in for, you can then check if a user cookie is set by using something like... if(isset($_COOKIE['cookie_name']) { //redirect user to profile page } else { //redirect to login page } you can use the same logic if you are going to store user data with sessions..but remember, there is a max time that a session can be stored, which can be set in your php.ini file...and if the user closes there brower, the session will be terminated, as opposed to cookies which will not terminate until either their time has expired or they are manually destroyed... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.