Jump to content

Logins


searls03

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/238824-logins/
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/238824-logins/#findComment-1227144
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.