开发者

In PHP session values get vanishing

In My code when I do login I am setting session values, in my config file, after that开发者_如何学C if I visit at any other page my session get vanished. A very strange situation, because I run same code in my lots of projects.

Please help me.

In top of the config I use session_start();


You have to include

session_start();

At the top of every page in which you use session variables. It's not enough to call it on one single page or calling it after you try using the session variables.


You have certain that you are run session_start()?

Try run:

var_dump(session_id());

If an empty string is returned, your session_start() don't be run. You can try:

@session_start();

Or do

session_commit();

On end of script.


try this PHP Session Variables


Check session.save_path in your php.ini. Do you see session files in that folder? Is it writable for PHP interpreter? Does your disk have enough free space for your session file?


When i met that kind of problem, i'll try to create a simple script just to check if the session is saved or not, if the session is not saved even for the simplest script, then i'll contact my hosting provider to check on my session save handler. A good hosting provider will likely check you your session save handler, and change the configuration as needed

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜