PHP session_encode() and session_decode()_PHP Tutorial

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

This article will introduce to you the usage of PHP session_encode() and session_decode(). Students who need to know more can refer to this example.

session_encode

session_encode — Encode the current session data into a string

Description
string session_encode ( void )
session_encode() returns a string containing the encoded current session data.

The code is as follows
 代码如下 复制代码

//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;
?>

Copy code

//boolean session_encode()

代码如下 复制代码

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";
}
?>

session_register ( 'bgcolor' ); session_register ( 'fontcolor' ); $id = session_id ( $usr_id );

$bgcolor = "white";

$fontcolor = "blue";$usr_data = session_encode (); print $usr_data; ?> session_decode
The code is as follows Copy code
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"; } ?> http://www.bkjia.com/PHPjc/628784.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/628784.htmlTechArticleThis article will introduce to you the usage of PHP session_encode() and session_decode(). Students who need to know more can refer to this article Example. session_encode session_encode encodes the current session data as...
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 Tutorials
More>
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!