Home  >  Article  >  Backend Development  >  How to use php session_decode function

How to use php session_decode function

藏色散人
藏色散人Original
2019-05-25 17:58:302730browse

php session_decode function is used to decode session data. Its syntax is bool session_decode (string $data), and the parameter data is the encoded data.

How to use php session_decode function

#How to use the session_decode function?

Function: Decode session data

Syntax:

bool session_decode ( string $data )

Parameters:

data, encoded data.

Description:

session_decode() decodes the serialized session data in the $data parameter, and uses the decoded data to fill the $_SESSION super global variable .

php session_decode() function usage example 1

<?php
session_start();
$_SESSION[&#39;login_ok&#39;] = true;
$_SESSION[&#39;nome&#39;] = &#39;sica&#39;;
$_SESSION[&#39;inteiro&#39;] = 34;
echo session_encode();
?>

Output:

login_ok|b:1;nome|s:4:"sica";inteiro|i:34;

php session_decode() function usage example 2

<?php
session_start();
$_SESSION[&#39;name&#39;] = "php中文网";
$_SESSION[&#39;id&#39;] = 1;
$_SESSION[&#39;pkey&#39;] = 1;
echo session_encode();
?>

Output:

name|s:12:"php中文网";id|i:1;pkey|i:1;

The above is the detailed content of How to use php session_decode function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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