Definition at line 4212 of file grima-lib.php.
◆ __construct()
| EncryptedCookieSession::__construct |
( |
|
$key |
) |
|
Definition at line 4220 of file grima-lib.php.
References $key.
4221 $this->session_key =
$key;
4222 $this->last_read =
"Not This";
◆ close()
| EncryptedCookieSession::close |
( |
|
) |
|
◆ destroy()
| EncryptedCookieSession::destroy |
( |
|
$session_id |
) |
|
Definition at line 4237 of file grima-lib.php.
4238 #error_log("session_destroy($session_id)");
4239 $params = session_get_cookie_params();
4240 $params[
'expires'] = time() - 42000;
4241 unset($params[
'lifetime']);
4242 setcookie( $this->session_name,
'', $params );
◆ gc()
| EncryptedCookieSession::gc |
( |
|
$maxlifetime |
) |
|
Definition at line 4246 of file grima-lib.php.
4247 #error_log("session_gc($maxlifetime)");
◆ open()
| EncryptedCookieSession::open |
( |
|
$save_path, |
|
|
|
$session_name |
|
) |
|
|
Definition at line 4225 of file grima-lib.php.
4228 #error_log("session_open($save_path,$session_name)");
◆ read()
| EncryptedCookieSession::read |
( |
|
$session_id |
) |
|
Definition at line 4251 of file grima-lib.php.
References $ciphertext, and $plaintext.
4252 #error_log("session_read($session_id)");
4253 $nonce_ciphertext_b64 = isset( $_COOKIE[$this->session_name] ) ? $_COOKIE[
$this->session_name] :
"";
4254 if ($nonce_ciphertext_b64) {
4255 $nonce_ciphertext = base64_decode( $nonce_ciphertext_b64 );
4256 if (strlen($nonce_ciphertext)>24+16) {
4257 $nonce = substr( $nonce_ciphertext, 0, 24 );
4260 #error_log("session_read -> $plaintext");
4264 error_log(
"cookie too short: $nonce_ciphertext_b64");
4267 #error_log("cookie not set or empty");
◆ write()
| EncryptedCookieSession::write |
( |
|
$session_id, |
|
|
|
$session_data |
|
) |
|
|
Definition at line 4272 of file grima-lib.php.
References $ciphertext.
4273 #error_log("session_write($session_id,$session_data)");
4274 if (!$session_data)
return true;
4275 if ($this->last_read == $session_data)
return true;
4276 $nonce = random_bytes(24);
4277 $ciphertext = sodium_crypto_secretbox( $session_data, $nonce, $this->session_key );
4278 $nonce_ciphertext = $nonce.$ciphertext;
4279 $nonce_ciphertext_b64 = base64_encode( $nonce_ciphertext );
4280 $options = session_get_cookie_params();
4281 if (isset($options[
'expires']) && $options[
'expires']) {
4282 $options[
'expires'] += time();
4284 unset($options[
'lifetime']);
4285 setcookie( $this->session_name, $nonce_ciphertext_b64, $options );
◆ $last_read
| EncryptedCookieSession::$last_read |
|
private |
◆ $save_path
| EncryptedCookieSession::$save_path |
|
private |
◆ $session_key
| EncryptedCookieSession::$session_key |
|
private |
◆ $session_name
| EncryptedCookieSession::$session_name |
|
private |
The documentation for this class was generated from the following file: