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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...