Session_cache_expire()

session_start() ;
$_SESSION['mySession'] = 1 ;
echo '<a href="result.php">to result.php</a><br>' ;

I have the code above in setSession.php.
And the code below in result.php.

session_start() ;
echo $_SESSION['mySession'].' <br>' ;
echo session_cache_expire() ;

After I open the setSession.php, I open result.php.
It says like the following.

(Q1) What does it mean by 180?
(Q2) Is that mean "after 3 hours, 180minuts, the value of $_SESSION[‘mySession’] will be not “1”?
(Q3) How can I change the value from ‘180’ to ‘5’ for testing?
( I think I need shorter time for seeing testing result)

Normally the session time is set in the php.ini file. But you can also set the expire time for one session just putting a value in the

session_cache_expire(minutes)

<?php
session_start() ;
session_cache_expire(2) ;

I made the code above in a page “expire.php” for killing the session 2 minutes later.
When I open the page above, it says the below.

How can I make the session is not active for working Session cache expiration correctly>

I like to remove the Waring above.

The free manual tells you exactly how to use it. Do you see what you are doing that is different than the manual says?

https://www.php.net/manual/en/function.session-cache-expire.php

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.