I have a login system on my website, and when a user comes onto the site they automatically get given a session id with sessions_start();
and then this sessions id is stored in our database.
But, our login system is only available for certain people with access, so when a user is logged in I want to set the session expiry to something like I dont know, 1 year or something like a long time so the users session doesn't expire when the browser is closed. Therefore saving them having to login every time they come onto the site basically.
Whether this is done via a "Remeber me" button or just done by default considering there isn't a large number of users that have access to be able to login. Not sure if this causes any security issues but if someone will some PHP knowledge could let me know that would be appreciated.
Asked
Active
Viewed 82 times
0
1 Answers
-1
No, you can not set a session for 1 year. What you want to do is, when the user login, you can set a cookie and set the cookie expiry to 1 year or for an amount of time you want.
Then when the user visits the site, you can check if the cookie is valid and if valid log them in automatically.
setcookie(COOKIE_NAME, YOUR_VALUE, EXPIRY_TIME);
See here for more details.

Dula
- 1,276
- 5
- 14
- 23