Home > php教程 > php手册 > PHP session_encode()和 session_decode()

PHP session_encode()和 session_decode()

WBOY
Release: 2016-05-25 16:48:12
Original
967 people have browsed it

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

session_encode

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

说明:

string session_encode ( void ) 

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

实例代码如下:

<?php
//boolean session_encode()
session_register(&#39;bgcolor&#39;);
session_register(&#39;fontcolor&#39;);
$id = session_id($usr_id);
$bgcolor = "white";
$fontcolor = "blue";
$usr_data = session_encode();
print $usr_data;
?>
Copy after login

session_decode

实例代码如下:

<?php
session_start();
$_SESSION = array();
session_decode("products|a:2:{i:0;s:8:\"Hal 2000\";i:1;s:6:\"Tardis\";}");
foreach ($_SESSION[&#39;products&#39;] as $p) {
    print "$p<br/>\n";
}
?>
Copy after login


文章地址:

转载随意^^请带上本文地址!

Related labels:
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template