0

Is there any way to set the life time on a specific session. For example let's say that I have 2 session:

$_SESSION['A']='1'

$_SESSION['B']='2'

I want, for example, change the life time on the session A, on 60s. Could I do this without using cookies (For avoid user manipulation)?

Zissouu
  • 924
  • 2
  • 10
  • 17
U. MJG
  • 47
  • 1
  • 9
  • 2
    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) – Shanu k k Sep 13 '17 at 12:24

2 Answers2

2

you could do like this to control particular session

    $_SESSION['first_session']="10";

    $now = time();
    if (isset($_SESSION['destroy_session']) && $now > $_SESSION['destroy_session']) {
        session_unset($_SESSION['first_session']);
    }

    $_SESSION['destroy_session'] = $now + 10; //10 secs


   echo $_SESSION['first_session'];

after 10 seconds your session will get empty.

0

Server side information should constantly deleted. For set life time session in php, you can use the function session_set_cookie_params, before the session_start.

session_set_cookie_params(3600,"/");
session_start();