开发者

PHP Session variables not passing across pages

Common problem, but I'm stumped. Session variables开发者_运维百科 are passing across pages on my local (localhost) deployment, but not on my (www) host. I use a common includes file for each page with this code:

$sessionDomain = "/";
@ini_set("session.cookie_path",$sessionDomain);
$sessionName = "ccSID".md5('/store/');
session_name($sessionName);
session_start();

I confirmed that the session ID cookie (ccSIDxxxxx...) remains the same across pages in my browser, but session variables don't seem to hold up when changing to a page in a different directory.

EDIT: My session cookie file has legible data from one path directory, but not another. I noticed that the good directory has a blank php.ini file in it. When I place a blank php.ini file in the bad directory, the session cookie becomes legible but then regular browser cookies don't save from pages in that directory. What's the deal with (blank) php.ini files in directories that change the behaviour of the session cookie?


"/" looks like a path, not domain.
Why don't you just leave session settings alone, with default values?
if session cookie goes all right, you have to check files within session.save_path


I have a sneaking feeling that you're saving cookies in more than one place. Since you're naming them yourself the name might be the same, but it would in effect be a completely different session.

Look on your server at the actual session files. Are they all where they're supposed to be? Are there a bunch showing up where they don't belong?

If this is the case it you're path is probably being set relative rather than absolute even though it doesn't look like it from what you've shown here.

Also, perhaps you should take the shutup operator (@) off of your ini_set() so you can see if it is complaining about anything?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜