Home > Backend Development > PHP Problem > PHP Session loss problem

PHP Session loss problem

coldplay.xixi
Release: 2023-03-06 11:10:01
Original
2547 people have browsed it

Solution to the problem of PHP Session loss: Add [session_id(SID);] before [session_start();], the code is [session_id(SID);session_start();$_SESSION['test' ]=””].

PHP Session loss problem

Solution to PHP Session loss problem:

Solution to session loss situation

In session_start (); add session_id(SID) before;

<?php
/*
*session1.php
*/
session_id(SID);
session_start();
$_SESSION[&#39;test&#39;]="HelloWorld!";
header("location:session2.php");
?><?php
Copy after login
/*
*session2.php
*/
session_id(SID);
session_start();
echo$_SESSION[&#39;test&#39;];
?>
Copy after login

If you want to learn more about programming, please pay attentionphp trainingColumn!

The above is the detailed content of PHP Session loss problem. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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