Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

Codeigniter session is not working on PHP 7

I am using codeigniter version 3.0.6 on PHP 5.6 and it works fine. but when I run same project on PHP 7.1 , codeigniter session is not working. I set session like below

$login_session = $this->session->set_userdata("user_session",$session_data);

when I print $login_session it is blank on PHP 7

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Recently I've faced the same problem by upgrading my php version from 5.6 to 7.1 My development environment is XAMPP (Apache + MariaDB) using php7.1.4

Please follow the below steps:

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

2) Comment session_start() by adding //.

3) Go down to line around 312-315 where it says Security is king, and comment out the following lines:

ini_set('session.use_trans_sid', 0);
ini_set('session.use_strict_mode', 1);
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
ini_set('session.hash_function', 1);
ini_set('session.hash_bits_per_character', 4);

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

5) Add session_start() at the top once.

It works for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...