Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

PHP Session values expire after ~30min, even though the cookie is set at 1 day

I'm having a weird problem (probably overlooking something small, but I can't find it).

My PHP session values get removed after approx 30minutes even though the cookie lifetime has been set to 1 day.


My PHP settings:
session.cookie_lifetime 86400 (1day)
session.gc_maxlifetime 86400 (1day)

Also when I check the cookie manually in the browser the PHPSESSID expires after 1 Day,

but when I set a value in it like this:
PHP Code

<?php 
$_SESSION
['referral'] = "username"; 

it seems to be gone after 30min?
Make sure you've restarted your server after saving those.

What OS are you running? Debian (some versions) will automatically clear the default php session folder after about 30 minutes.
(Apr 9, 2018 08:07 AM)Charger Wrote:  Make sure you've restarted your server after saving those.

What OS are you running? Debian (some versions) will automatically clear the default php session folder after about 30 minutes.

Restarting PHP has no effect.

OS: Ubuntu 16.04.2 LTS

How would I resolve the automatic clearing if that's whats happening, Just set it manually to a new folder that's not the default one?

the garbage collector settings:
session.gc_divisor 1000
session.gc_probability 0
(Apr 9, 2018 08:18 AM)Pim Fortuyn Wrote:  Restarting PHP has no effect.

OS: Ubuntu 16.04.2 LTS

How would I resolve the automatic clearing if that's whats happening, Just set it manually to a new folder that's not the default one?

the garbage collector settings:
session.gc_divisor 1000
session.gc_probability 0

Change those to
session.gc_probability = 1
session.gc_divisor = 1000

No need to divide by 0 and clean up needs to occur at some point.


Make sure you're editing the right version of PHP (5 or 7). Ubuntu doesn't have any garbage collecting issues AFAIK.
(Apr 9, 2018 08:25 AM)Charger Wrote:  Change those to
session.gc_probability = 1
session.gc_divisor = 1000

No need to divide by 0 and clean up needs to occur at some point.


Make sure you're editing the right version of PHP (5 or 7). Ubuntu doesn't have any garbage collecting issues AFAIK.

I think I had it at 0 from testing, I've set the probability back to 1 and the devisor to 100,

What else could I try to fix the session variables expiring so fast?
(Apr 9, 2018 09:07 AM)Pim Fortuyn Wrote:  I think I had it at 0 from testing, I've set the probability back to 1 and the devisor to 100,

What else could I try to fix the session variables expiring so fast?

Have you checked the cron job? Charger said it will automatically clear the session.
[Image: signaturetwo.png]
Are you using cookies for the session? Perhaps, your browser security settings are deleting the cookie?
(Apr 9, 2018 09:56 AM)Vyxn Wrote:  Have you checked the cron job? Charger said it will automatically clear the session.

Yeah, there are no cronjobs, besides one I have created but it doesn't clear the cookies.


(Apr 9, 2018 10:09 AM)m0noxide Wrote:  Are you using cookies for the session? Perhaps, your browser security settings are deleting the cookie?

I also had people test it and the same issue. Its very unlikely its an issue with my own browser.
Check the dir where the sessions are being stored. See if there is anything in there.
Can you post your php.ini file or the part with the sessions?
(Apr 10, 2018 09:01 AM)Hapi Wrote:  Can you post your php.ini file or the part with the sessions?

Sorry for the late reply, but I've included my settings at the top.


(Apr 10, 2018 08:15 AM)Charger Wrote:  Check the dir where the sessions are being stored. See if there is anything in there.

There is, its full of files which I assume are sessions


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Javascript]  by HardStoNNov 16, 2020 09:19 AM 12 332 Nov 16, 2020 09:19 AM
Last Post: woodly
[PHP] by AussieMay 3, 2020 06:00 AM 2 142 May 3, 2020 06:00 AM
Last Post: Aussie
[PHP] by faxxgridApr 30, 2020 11:45 AM 15 371 Apr 30, 2020 11:45 AM
Last Post: faxxgrid