且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在CodeIgniter 3.1.2中重定向后,会话数据丢失

更新时间:2023-11-13 22:15:04

我不确定到底是什么问题。最近,我也遇到了这个问题。

I'm not sure what exactly is the problem. Recently I faced this too..

在运行php7.0的开发环境中,此功能以前一直有效。

It was working before in my development running php7.0.

当前它仅在运行nginx和php 5.6的生产服务器中工作。我的开发服务器似乎无法正常工作,并继续在会话表中重新生成新行。我的开发服务器在homestead virtualbox开发环境上使用的是php7.1,通常用于Laravel项目。

Currently it is only working in my production server running nginx and php 5.6. My development server seems to be not working and keeps on regenerate new row in sessions table. My development server is using php7.1, on homestead virtualbox development environment, usually being used for Laravel projects.

我设法通过这一步骤克服了这一点。

I managed to get over this by taking this step.

1)转到system / libraries / Session / Session.php

1) Go to system/libraries/Session/Session.php

2)通过添加/来注释session_start() /。我们要重新定位sessionn_start()。

2) Comment session_start() by adding //. We want to relocate the sessionn_start().

3)向下转到第315行,说安全为王,然后注释掉直到第351行

3) Go down to line 315 where it says Security is king, and comment out until line 351

4)然后转到主index.php(根索引。 php)

4) Then go to your main index.php ( the root index.php )

5)在顶部一次添加session_start()。

5) Add session_start() at the top once.

6)好的,再试一次。希望它能工作。我的猜测是它不能与php 7.1一起使用,并且需要在此Session.php文件中进行一些更新。

6) Okay try again. Hopefully it works. My guess is that it is not working with php 7.1 and some update need to be done in this Session.php file.

我的CI版本是3.1.1

My CI Version is 3.1.1