PHP session_cache_expire() Function

What is session_cache_expire Function?

Explanation

The "session_cache_expire()" function returns current cache expire.

Syntax:


session_cache_expire(string)

In the above syntax the user can set the session cache expire time, usually a default value of 180 seconds is set in the session.cache_limiter, so session cache expire should be called before the session start() function.

Example :


<?php
session_cache_limiter('private');
$cache_limiter = session_cache_limiter();
session_cache_expire(30);
$cache_expire = session_cache_expire();
session_start();
echo "The cache limiter is now set to $cache_limiter<br />";
echo "The cached session pages expire after $cache_expire minutes";
?>
Result :

The cache limiter is now set to private
The cached session pages expire after 30 minutes

In the above example, the first session cache limiter is set to "private", so that the session cache expire can be set to 30 minutes, only after that the session_start function is called.

PHP Topics


Ask Questions

Ask Question