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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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