1

Trying to limit a session to one minute, but somehow the session is still available after 1 minute. Am I using it wrong? I read that when I set a Value the session will expire in X Minutes, but sadly they don't.

Here's the code:

<?php
   session_cache_limiter(1);
   session_start();

   if( isset( $_SESSION['counter'] ) ) {
      $_SESSION['counter'] += 1;
   }else {
      $_SESSION['counter'] = 1;
   }

   $msg = "You have visited this page ".  $_SESSION['counter'];
   $msg .= " times in this session.";
?>
Mirza Sisic
  • 2,401
  • 4
  • 24
  • 38
user3220962
  • 371
  • 1
  • 7
  • 19
  • 1
    the manual defines it like `string session_cache_limiter ([ string $cache_limiter ] )` and uses examples like `session_cache_limiter('private');$cache_limiter = session_cache_limiter();` – Professor Abronsius Aug 12 '16 at 09:57
  • Well, guess i understand what mistake i made. thanks! – user3220962 Aug 12 '16 at 10:01
  • 1
    Possible duplicate of [How do I expire a PHP session after 30 minutes?](https://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes) – Ravi Oct 09 '17 at 15:52

0 Answers0