php - ci cannot set session problem
ringa_lee
ringa_lee 2017-06-17 09:15:22
0
1
930

I wrote a login page using ci, the code is as follows:

print_r($this->session->userdata());
$this->session->set_userdata('test',rand(564,489426354465));
echo '<br>';
print_r($this->session->userdata());

Output:


Array ( [__ci_last_regenerate] => 1497598658 ) 
Array ( [__ci_last_regenerate] => 1497598658 [test] => 115826667932 )

No matter how many times the page is refreshed, the value of test does not exist in the session, but the timestamp of __ci_last_regenerate has increased. Why is this? Has anyone encountered this situation?

Check 1, it is not a php configuration problem. I created a php file in the root directory. The code is as follows. The correct session can be output every time

session_start();
ob_start();

print_r($_SESSION);
$_SESSION['test'] = rand(456,4984945569);
print_r($_SESSION);
ringa_lee
ringa_lee

ringa_lee

reply all(1)
大家讲道理

The original ci version was 3.1.0 (a constant defined in /system/core/CodeIgniter.php). Later, it was overwritten with all the files in the system of 3.1.3, and the problem was solved. This is considered 3.1. 0 bugs?

I used php5.5 before, but changed it to php7.1.4 a few days ago. I don’t know if this is the reason

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template