Sessions table

Open to all! Ask other shopowners for help.
Post Reply
User avatar
alix32
Member
Posts: 14
Joined: Mon Oct 26, 2020 11:22 am
Phoenix Version: v1.0.7.6
Has thanked: 1 time
Been thanked: 1 time

Sessions table

Post by alix32 »

Hi - my sessions table is filling up quite quickly. While I do have sufficient space to carry on for a while, what would be the impact to wiping out some of that stored data? Returning visitors who had items to their cart may not see their "carted" items any more? Trying to size the impact before I do anything bad

Thanks!
Current Phoenix Version in prod: 1.0.7.6


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Sessions table

Post by ecartz »

By default, all sessions that are older than maxlifetime are supposed to get cleared whenever the garbage collector runs. See https://github.com/CE-PhoenixCart/Phoen ... ns.php#L45

If the garbage collector settings from php.ini are not working correctly, it should be harmless to run

Code: Select all

DELETE FROM sessions WHERE expiry < NOW() - INTERVAL 1 WEEK
in phpMyAdmin or wherever. This is supposed to happen on some regular basis. It shouldn't affect returning visitors, as they should get new session IDs regardless. The problematic deletion would be visitors who currently have their browser open. Hopefully there aren't that many visitors who have their browser open for more than a week between visits.

Because the database date and the server date may be different, I don't know that it would be a good idea to set the interval to less than 3 DAY. 1 WEEK or 1 MONTH or 1 YEAR should be fine. You might try starting with the longest interval and seeing how much that helps. You can then decrease down step-by-step to a week if not.
Omar_one
Senior Contributor
Posts: 676
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: Sessions table

Post by Omar_one »

there is add-on (Session Expiration Control) made for older version of Community Bootstrap Edition (BS Edge) by Demitry , to allows the store owner to manage their admin panel's session expiration, as well as the customer's session expiration via Admin>Configuration>Sessions.

I didn't test on Phoenix also it's need some core change,,
GdNico
Member
Posts: 18
Joined: Tue Jul 20, 2021 8:43 pm
Phoenix Version: v1.1.0.1
Has thanked: 2 times
Been thanked: 4 times

Re: Sessions table

Post by GdNico »

Hi everyone,

now that there is no longer $maxlifetime or even _sess_gc() in the functions (at first sight since 1.0.9?) and that the core moved to a class "session", how are the sessions deleted ?

I post the question because I have just been forced to delete 1.6 GB in the table "sessions" (knowing that my database does not exceed 100MB ...)

thanks a lot for all
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Sessions table

Post by heatherbell »

GdNico wrote: Tue Dec 10, 2024 5:59 pm now that there is no longer $maxlifetime or even _sess_gc() in the functions (at first sight since 1.0.9?) and that the core moved to a class "session", how are the sessions deleted ?
As in previous post (read the whole post for detailed instructions):
ecartz wrote: Wed Mar 31, 2021 11:09 am By default, all sessions that are older than maxlifetime are supposed to get cleared whenever the garbage collector runs.
The function moved in v1.0.8.3 to:
https://github.com/CE-PhoenixCart/Phoen ... hp#L24-L27
where session.gc_maxlifetime is set in php.ini, usually default of 1440 seconds (24 minutes).
It might not be possible to see or change that value on a hosted server cPanel.
It is possible to check the current session.gc_maxlifetime setting by running this in a PHP script:

Code: Select all

echo ini_get('session.gc_maxlifetime');
Otherwise check with the hosted server provider.
MyGamesShop
Contributor
Posts: 131
Joined: Wed Mar 10, 2021 3:02 am
Phoenix Version: v1.1.0.6
Has thanked: 8 times
Been thanked: 5 times

Re: Sessions table

Post by MyGamesShop »

I posted about this here: viewtopic.php?f=10&t=2235

I have installed Zip's firewall which has assisted a fare bit in identifying and stopping bad actors.
I then promote these IP bans to a real firewall in place to handle Amazon's Claudebot however
as the IP bans are now in the millions.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply