PHPSESSID

Status
Not open for further replies.

fawk_mod70

New Member
Messages
8
Reaction score
0
Points
1
Hello, I have a question. Why does my PHPSESSID expire so fast on my free hosting account? Now before you say it's because of my script. Please take note that the PHPSESSID cookie is still on my browser with an expiration date of next year. How is it possible that the PHPSESSID on my end hasn't expired, but my free hosting account domain cannot keep my session until next year (if you say this is a bad idea, I already have session_regenerate_id() on)?

The main problem is that every time I want to log on my script, my session cookie expires after a second, but keeps my PHPSESSID cookie on my end.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
You should be getting far more than a second out of the deal, but you won't get a year by any means without playing with the server configuration (or using database sessions instead of file sessions). At the server end, a session (by default) is a temporary file that will be deleted eventually that corresponds with a session ID assigned to the user. When the user hits the server again, the user's session file is re-opened (or read, destroyed and recreated if you're regenerating). Even if the cookie is still good, when the session file is deleted, the session no longer exists.

Persistent login ("remember me") generally requires a login token cookie that can be used to automatically log the user in without them having to re-enter their credentials. Keeping a persistent session means configuring the server to keep session files for an extended period of time, and that usually means having control of the server (such as with a VPS). Since you don't have that ability with a shared/managed sever, you generally have to use a login token rather than a long-lived session ID.

Again, though, you shouldn't be getting booted during a continuous activity session. The session garbage collection lifetime should be long enough for most activity pauses, and you can always have something on the page ping the server (making a small request) if you're building something that requires long periods of activity on the page that doesn't otherwise require server interaction. I don't know what the session.gc_maxlifetime is on the Free Hosting servers offhand, but the default is usually around 24 minutes (1440 seconds), after which the server essentially has permission to kill the file if it hasn't been read/written. Once that happens, the session no longer exists, and the fact that you still have a valid PHPSESSID cookie doesn't change that.
 

fawk_mod70

New Member
Messages
8
Reaction score
0
Points
1
You should be getting far more than a second out of the deal, but you won't get a year by any means without playing with the server configuration (or using database sessions instead of file sessions). At the server end, a session (by default) is a temporary file that will be deleted eventually that corresponds with a session ID assigned to the user. When the user hits the server again, the user's session file is re-opened (or read, destroyed and recreated if you're regenerating). Even if the cookie is still good, when the session file is deleted, the session no longer exists.

Persistent login ("remember me") generally requires a login token cookie that can be used to automatically log the user in without them having to re-enter their credentials. Keeping a persistent session means configuring the server to keep session files for an extended period of time, and that usually means having control of the server (such as with a VPS). Since you don't have that ability with a shared/managed sever, you generally have to use a login token rather than a long-lived session ID.

Again, though, you shouldn't be getting booted during a continuous activity session. The session garbage collection lifetime should be long enough for most activity pauses, and you can always have something on the page ping the server (making a small request) if you're building something that requires long periods of activity on the page that doesn't otherwise require server interaction. I don't know what the session.gc_maxlifetime is on the Free Hosting servers offhand, but the default is usually around 24 minutes (1440 seconds), after which the server essentially has permission to kill the file if it hasn't been read/written. Once that happens, the session no longer exists, and the fact that you still have a valid PHPSESSID cookie doesn't change that.
Can I PM you my script? I'm trying to host (demo version) a script that I am selling, but I don't want people to see it.
 

fawk_mod70

New Member
Messages
8
Reaction score
0
Points
1
Ok, I'm bringing this issue up again. I know that me and @essellar have had a decent amount of chat about this. However I just now have tested my script on Byethost and it seems that they are able to keep me logged in on my forum for a long time. The same pages I have on Byethost, I can't stay logged in on x10hosting for more than a second. I don't want to use Byethost because I've had many issues with them in the past. Can there be any solution for this problem besides creating and storing sessions in the database?
 
Status
Not open for further replies.
Top