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

PHP Session loss problem

coldplay.xixi
coldplay.xixiOriginal
2020-09-30 14:31:382593browse

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
/*
*session2.php
*/
session_id(SID);
session_start();
echo$_SESSION[&#39;test&#39;];
?>

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!

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