Voting

: max(two, seven)?
(Example: nine)

The Note You're Voting On

polygon dot co dot in at gmail dot com
2 years ago
Although, session_set_save_handler() has support for saving session data via other modes, This does not support a way for saving session data in COOKIES. This is required for a site with a huge concurrent request the recommended solution by session_set_save_handler() does not fit the load site is handling.
So, the other way around to do this is as below.

<?php
// start.php
ob_start(); // Turn on output buffering

$sessCookieName = session_name();
$_SESSION = json_decode(base64_decode($_COOKIE[$sessCookieName]), true);

// Code
function echosess() {
echo
$_SESSION['id'];
}
echosess();
$_SESSION['id'] = 1;

// end.php
$op = ob_get_clean(); // Get current buffer contents and delete current output buffer
$encryptedData = base64_encode(json_encode($_SESSION));
setcookie($sessCookieName, $encryptedData, time() + (ini_get("session.gc_maxlifetime")), '/');
echo
$op;
?>

If more security is required about the data of the session in cookie, then key based encryption/decryption can solve the issue.

<< Back to user notes page

To Top