Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP session expires but after page refresh I'm not redirected
    primarykey
    data
    text
    <p>Problem is, when my session expires I have to reload page twice to get back to login page. here is my .htaccess file</p> <pre><code>php_flag display_errors on php_value error_reporting 9999 RewriteEngine On Options -MultiViews AddDefaultCharset UTF-8 php_value session.gc_maxlifetime 5 php_value session.gc_divisor 1 php_value session.gc_probability 1 php_value session.cookie_lifetime 5 php_value session.save_path /path/to/session/folder RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] </code></pre> <p>I'm using some custom MVC framework and I'm calling handleLogin() function in controllers __construct function</p> <pre><code>function __construct() { parent::__construct(); Auth::handleLogin(); } </code></pre> <p>And finally here is handleLogin() function</p> <pre><code>public static function handleLogin() { @session_start(); if (isset($_SESSION['loggedIn'])) { $logged = $_SESSION['loggedIn']; } else { session_destroy(); header('location: ' . URL . 'login'); exit; } } </code></pre> <p>What do I need to change to redirect user to Login page after FIRST refresh when session expires?</p> <p>Thanks in advance!</p> <p>P.S. I'm running it on Debian</p> <p>UPDATE: here is logout function and it works fine, when user clicks it he is immidiately redirected to login page</p> <pre><code>function logout() { session_destroy; header('location: ' . URL . 'login'); exit; } </code></pre> <p>UPDATE #2 I got some screenshots for better problem description</p> <p>1) When session is active and everything works fine <img src="https://i.stack.imgur.com/OJ7Cd.jpg" alt="enter image description here"></p> <p>2) session expired - user clicks link or refresh page (after first refresh) as you can notice in firebug login is loaded but it's not shown <img src="https://i.stack.imgur.com/0YVto.jpg" alt="enter image description here"></p> <p>3) after 2nd refresh <img src="https://i.stack.imgur.com/5tfqA.png" alt="enter image description here"></p> <p>One more thing is.. when using default <strong>php.ini settings</strong> (session lifetime: 1440 sec) everthing works fine with no problem in redirecting</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload