Hi,
In my database, the number of sessiontokens keeps growing (four times the size of the rest of the data) and don't seem to expire/disappear. How do I keep them to a minimum/reasonable size? I'm on v1.0.8.20.
Thanks, Eddy
Sessiontoken - Are they supposed to keep growing?
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: Sessiontoken - Are they supposed to keep growing?
Hoping that it helps, after researching your question, the best explanation I have found is on this thread link here:
https://www.oscommerce.com/forums/topic ... ions-table
If I understand correctly, it seems to be dependent on server PHP settings, e.g. we have no issues with old sessions being cleared automagically on any of our sites (running various versions from 1.0.5.0 to 1.0.8.20).
Guessing that is done in core here:
https://github.com/CE-PhoenixCart/Phoen ... hp#L23-L25
If you go down the route of a SQL query, when dealing with timestamps, a timestamp converter is useful, e.g. https://unixtime.org/
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Sessiontoken - Are they supposed to keep growing?
It might be easier to just do what gc does:heatherbell wrote: ↑Sun Feb 26, 2023 6:45 am If you go down the route of a SQL query, when dealing with timestamps, a timestamp converter is useful, e.g. https://unixtime.org/
Code: Select all
$GLOBALS['db']->query("DELETE FROM sessions WHERE expiry < '" . (int)strtotime('-1 week') . "'");If you do it in phpMyAdmin, you can use UNIX_TIMESTAMP, e.g.
Code: Select all
DELETE FROM sessions WHERE expiry < UNIX_TIMESTAMP(NOW() - INTERVAL 1 WEEK)Code: Select all
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 100);
init_set('session.gc_max_lifetime', 604800);Most likely your php.ini file has either session.gc_probability or session.gc_max_lifetime set to 0, disabling the check.
https://www.php.net/manual/en/session.c ... robability