Jump to content
AnotherAndrew

Session time for logged in user

Recommended Posts

Is there a way to change the session time before a user is automatically logged off? I see that PW automatically logs off an admin user after a set amount of time, but what about a new user role that I created?

Share this post


Link to post
Share on other sites

Take a look in /site/config.php. A few lines down you'll see this line:

<?php
/**
* sessionExpireSeconds: how many seconds of inactivity before session expires
*
*/
$config->sessionExpireSeconds = 86400;

Change that to adjust how long you want sessions to last.

Share this post


Link to post
Share on other sites

Is it possible to do this:

		if($user->isSuperuser()) $config->sessionExpireSeconds = 86400; 
        else $config->sessionExpireSeconds = 23200;     

Share this post


Link to post
Share on other sites

You'd have to use a little bit different approach because a session has to be active before we know who the user is. The session hasn't yet started when the config file is being loaded. So you'd detect who the user is somewhere else (like in your main site template) and then set a cookie before any output starts:

setcookie('guest', $user->isGuest() ? 1 : 0); 

Then detect the cookie in your config.php:

$config->sessionExpireSeconds = empty($_COOKIE['guest']) ? 86400 : 23200; 

You wouldn't want to use this method for anything security related, but session time is really not a security concern I don't think.

Share this post


Link to post
Share on other sites

Hi!

I set this sessionExpireSeconds to 432000 in my confog.php

$config->sessionExpireSeconds = 432000;

I expected to be not automatically logged out for 5 days.
But i have to log in the very next day or even earlier.

Do i need to install another modul or did i made a mistake?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...