PHP session_encode()和 session_decode()_PHP教程

WBOY
Release: 2016-07-13 17:15:34
Original
1095 people have browsed it

本文章来给大家介绍PHP session_encode()和 session_decode() 用法,有需要了解的同学可参考本实例。

session_encode

session_encode — 将当前会话数据编码为一个字符串

说明
string session_encode ( void )
session_encode()返回一个字符串,该字符串包含有被编码的当前会话数据。

代码如下 复制代码


//boolean session_encode()
session_register ( 'bgcolor' );
session_register ( 'fontcolor' );

$id = session_id ( $usr_id );

$bgcolor = "white";
$fontcolor = "blue";

$usr_data = session_encode ();

print $usr_data;
?>

session_decode

代码如下 复制代码


session_start();
$_SESSION = array();
session_decode( "products|a:2:{i:0;s:8:"Hal 2000";i:1;s:6:"Tardis";}" );
foreach ( $_SESSION['products'] as $p ) {
print "$p
n";
}
?>

www.bkjia.com true http://www.bkjia.com/PHPjc/628784.html TechArticle 本文章来给大家介绍PHP session_encode()和 session_decode() 用法,有需要了解的同学可参考本实例。 session_encode session_encode 将当前会话数据编码为...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!