-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session will live for only 24 minutes no matter what #25
Comments
Same issue here.
Doesn't help |
Sorry, the language there is confusing. Sessions will live for 30 minutes, but their expiration is reset after 24 minutes using the expiration variant. Setting the Essentially, for the first 24 minutes after being created, nothing will change unless you tell it to. After those 24 minutes expire, the expiration is updated so the session stays alive. If you pass the 30 minute expiration window, then the session expires automatically. |
I need my sessions to live for days, without user having to login in 24-30 minute window. I've debugger plugin extensively and no matter where i set it,
always returns default value https://github.com/ericmann/wp-session-manager/blob/master/class-wp-session.php#L116 |
|
Did that. |
Sorry, hold on. There are two things going on here. An expiration (which you want to live for a day) and an expiration variant (a timeout to prevent updating the session too quickly). By default, the expiration is 24 minutes. To make it 24 hours, use:
To make the variant wait until, say, 20 hours before refreshing the session, use:
|
I understand the difference. |
I have to agree with artyomboyko. I tried applying both the In my functions.php add_filter('wp_session_expiration', 'extend_session_expiration', 10);
function extend_session_expiration($value) {
return 48 * 60 * 60;
}
add_filter('wp_session_expiration_variant', 'extend_session_expiration_variant', 10);
function extend_session_expiration_variant($value) {
return 24 * 60 * 60;
} Yet, in error_log((int) apply_filters( 'wp_session_expiration_variant', 24 * 60 ));
error_log((int) apply_filters( 'wp_session_expiration', 30 * 60 )); I just get the default value in my logs
I checked everywhere else in my code just in case |
FWIW I have the same problem, no matter where I put:
It has no effect on the expiration or expiration_variant. |
It's because the session is created in the I worked around this by creating a small custom plugin that can apply the custom filters before the WP Session plugin initialises for the first time. Add something like the following to a custom plugin file: add_action('plugins_loaded', function () {
add_filter('wp_session_expiration_variant', function () {
return 20 * 60 * 60;
});
add_filter('wp_session_expiration', function () {
return 24 * 60 * 60;
});
}, 1); |
It has been a while, but @joelambert his solution works. It would be nice if the plugin FAQ would also be updated on the WordPress plugin page (wordpress dot org/plugins/wp-session-manager/). |
@ericmann how do we handle this in 3.0? |
First of all make a wrapper class, so that its easier to maintain your sessions:
Since 3.0 makes use of the default global session variable, we have to keep track of the expiration ourselfs.
I hope this is what you are looking for. |
Since we're using native session functionality, you can either:
|
@ericmann The foremost reason to use a wrapper class is that you can (and did 👎 ) change how the library works. When I updated to version 3.0 in the beginning, all I had to do is change my functions, which only took 2 min. Others have had problems since they used your code through their whole project and had to change it everywhere. No bad feelings, but not recommending without a valid reason makes no sense. Besides the above, I do like your solution to hook on the |
@Tklaversma Version 3.0 was not intended to be backwards compatible. This is why the major version incremented from 2.X to 3.X. That being said, community members have contributed a patch to the latest version (3.0.3) that brings back the global With this change, |
Hi Eric,
First of all, amazing plugin!
My problem.
It seems to me that no matter what, the sessions will only live for 24 minutes. If I read a session variable after it has been set 10 minutes ago, the expiration should reset to 24 minutes, right?
"By default, session variables will live for 24 minutes from the last time they were accessed - either read or write."
I use the following code to set an variable on page load
and use the following to read. If session doesn't exist, I redirect to the login page.
Hope you can help me out.
Regards,
TK
The text was updated successfully, but these errors were encountered: