Hi @okorieware,
You can change the session lifetime with the pantheon_session_expiration
filter. Something like this should do the trick:
add_filter( 'pantheon_session_expiration', function() { return HOUR_IN_SECONDS * 24; } );
Hope this helps!
Thank you very much @danielbachhuber
Well,
I’ve monitored Pantheon Sessions under wp-admin for the past few days, but still find that sessions are not automatically cleared after my set period.
The following is what I’m using:
add_action("plugins_loaded", function () {
add_filter("pantheon_session_expiration", function() {
// todo: 24 hours
return HOUR_IN_SECONDS * 6;
});
Can I genuinely clear them automatically?
I don’t want defunct sessions to be accumulating.
-
This reply was modified 4 years, 8 months ago by
OkorieWare. Reason: typo
Hi @okorieware,
The pantheon_session_expiration
filter sets the session.cookie_lifetime
setting, which:
specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means “until the browser is closed.” Defaults to 0.
With the code snippet you shared, a cookie will be valid for 6 hours.
If this isn’t what you want, can you describe with a bit more detail about what you’re trying to do?
Hi @danielbachhuber,
What I want is to automatically clear sessions older than 24 hours from Native PHP Sessions database, the one that appears under “wp-admin \ Pantheon Sessions” with the “Clear All” button.
Makes sense, thanks for clarifying 🙂
Here’s a code snippet that registers a twice-daily cron job to delete all sessions older than 24 hours: https://gist.github.com/danielbachhuber/c49a6bccfd2fbeab5512c376dd1c5b36
Hi there. I copy the code that you’ve give here. But it does not work.
add_filter( 'pantheon_session_expiration', function() { return 300; } );
Am I missing something here?