Home > Backend Development > PHP Problem > How to use php session_decode function

How to use php session_decode function

藏色散人
Release: 2023-02-22 18:54:01
Original
2879 people have browsed it

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 )
Copy after login

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();
?>
Copy after login

Output:

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

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();
?>
Copy after login

Output:

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

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!

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