session_cache_expire()
session_cache_expire() — Get and/or set current cache expire.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
session_cache_expire() returns the current setting of session.cache_expire.
Signature
session_cache_expire(?int $value = null): int|false
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $value | ?int | If value is given and not null, the current cache expire is replaced with value. |
Return value
Returns the current setting of session.cache_expire. The value returned should be read in minutes, defaults to 180. On failure to change the value, false is returned.
Example
A runnable snippet:
/* set the cache limiter to 'private' */ session_cache_limiter('private'); $cache_limiter = session_cache_limiter(); /* set the cache expire to 30 minutes */ session_cache_expire(30); $cache_expire = session_cache_expire(); /* start the session */ session_start(); echo "The cache limiter is now set to $cache_limiter<br />"; echo "The cached session pages expire after $cache_expire minutes";
Changelog
| Version | Change |
|---|---|
| 8.0.0 | value is nullable now. |
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page session_cache_expire() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.