<?php
// URL:
http://pc3.purasbar.com/temp/11504/2.php//session_start();
//var_dump(session_get_cookie_params());
/* Keep the session file on the server side (For all session variables) */
$previous = session_cache_expire();
session_cache_expire(86400 * 365);
$now = session_cache_expire();
/* All session variables stored on the server side will expire in 365 days */
session_start();
/* Keep the cookie on the client side */
setcookie(session_name(), session_id(), time() + 86400); // keep 1 day
// Note: Do not use session_set_cookie_params(500), which should be put before session_start()
//setcookie(session_name(), session_id(), 0); // default setting: it will expire when the browser closes (0 can be omitted)
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Session Expire</title>
</head>
<body>
Session ID: <?=session_id()?><br>
<?php
if (isset($_SESSION["name"])) {
echo $_SESSION["name"] . ": " . $_SESSION["counter"];
$_SESSION["counter"]++;
} else {
echo "Lost";
$_SESSION["name"] = "Counter";
$_SESSION["counter"] = 1;
}
echo "<br><br>\n<b>On the server side:</b><br>\n";
echo "Previous: $previous<br>\nNow: $now";
?>
</body>
</html>