session_encode
(PHP 4, PHP 5, PHP 7)
session_encode — Encodes the current session data as a session encoded string
Описание
string session_encode
( void
)
session_encode() returns a serialized string of the contents of the current session data stored in the $_SESSION superglobal.
By default, the serialization method used is internal to PHP, and is not the same as serialize(). The serialization method can be set using session.serialize_handler.
Возвращаемые значения
Returns the contents of the current session encoded.
Примечания
Внимание
Must call session_start() before using session_encode().
Смотрите также
- session_decode() - Decodes session data from a session encoded string
- session.serialize_handler
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с сессиями
- Управление сессиями
- session_abort
- session_cache_expire
- session_cache_limiter
- session_commit
- session_create_id
- session_decode
- session_destroy
- session_encode
- session_gc
- session_get_cookie_params
- session_id
- session_is_registered
- session_module_name
- session_name
- session_regenerate_id
- session_register_shutdown
- session_register
- session_reset
- session_save_path
- session_set_cookie_params
- session_set_save_handler
- session_start
- session_status
- session_unregister
- session_unset
- session_write_close
Коментарии
session_encode() just return the session dataset in a formatted form
session_start();
$_SESSION['login_ok'] = true;
$_SESSION['nome'] = 'sica';
$_SESSION['inteiro'] = 34;
echo session_encode();
this code will print
login_ok|b:1;nome|s:4:"sica";inteiro|i:34;
session_encode() can't handle pipes in your keys.
<?php
session_start();
$_SESSION = ['foo|bar'=>'ba;z']; pathetic
dump(session_encode()); // false because "foo|bar" contains a pipe
?>