469,323 Members | 1,560 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

PHP Sessions doesn't work on my localhost

On my computer, whenever a new page is opened, a new session id will be
created instead of accessing the same session id.

When I upload everything on my webhost, it seems to work normal. So
there's no problem with my code. But I want it to work on my local
machine too, because it's better for me to program my website.

I've PHP running on my IIS server ( so, it's not Apache ). Is that the
problem? I've heard about a problem with sessions under IIS. Or do I
have incorrect settings in my php.ini.

Can someone help my. I don't know what to do anymore. If it's the IIS
problem, can it be fixed under IIS?

Aug 10 '05 #1
5 11603
*** Tommy DN wrote/escribió (10 Aug 2005 13:25:05 -0700):
Or do I have incorrect settings in my php.ini.


At a minimum, the session save directory should exist. Does it?
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Aug 11 '05 #2
Alvaro G Vicario schreef:
*** Tommy DN wrote/escribió (10 Aug 2005 13:25:05 -0700):
Or do I have incorrect settings in my php.ini.


At a minimum, the session save directory should exist. Does it?


Yes, my sessions directory is in " c:\php\sess\ " and all files are
saved in it. But when you refresh the page of when you come to another
page where the session is initilized ( with session_start() ), a new
file will be created in it instead of using the same session.

Aug 11 '05 #3
*** Tommy DN wrote/escribió (11 Aug 2005 03:23:58 -0700):
Yes, my sessions directory is in " c:\php\sess\ " and all files are
saved in it. But when you refresh the page of when you come to another
page where the session is initilized ( with session_start() ), a new
file will be created in it instead of using the same session.


Then it seems your web browser is not storing session cookies. Does it
happen with all browsers?

HTTP headers can be helpful for troubleshooting. You can see them with the
'Live HTTP Headers' extension (available for Mozilla and, probably,
Firefox).

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Aug 11 '05 #4
I have the exact same problem except I run apache.

It started when my hard drive recently crashed. I had been on win 2000
but when I installed the new drive I updated to XP. I then reloaded
Apache, PHP and MySQL, all the latest versions (this was in June).

Since then, when I run PHP pages on my machine, I have found that the
sessions are not maintaining from page to page. When I run the same
scripts on my ISP they work perfectly though.

I did find that in some instances if I put the session ID in the url I
can get things to work. But otherwise the session changes each time I
change or reload the page.

My initial assumptions are that I have some setting wrong in php.ini or
the appache configuration or there's some interaction with XP.

Did you come up with any solutions yet?

Thanks,
Jonathan

Aug 14 '05 #5
I had the same problem you had:
My sessions would start just fine, and a session file would be created and written to disk. (BTW, I'm on a win XP box, Apache 2.0.54, PHP version 5.0.4.) However, next time I loaded the page, the old session would not be used. Instead, a NEW session was created. For me, this happened no matter what computer I was using, whether it was the server (localhost) or a client (remote). A new session was created EVERY TIME I loaded the page.. it was annoying. After a few hours of googling, I gave up and decided to mess around in the php.ini file. I changed this line:
session.cookie_path = /
to this:
session.cookie_path =

I havent tried many things but I think maybe it is because windows needs backslashes (\) instead of forward slashes (/), and if you just leave it blank, it turns out ok.

hope this helps.
Aug 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Steve Fitzgerald | last post: by
3 posts views Thread by Simon K | last post: by
reply views Thread by Jerad Rose | last post: by
1 post views Thread by Duncan | last post: by
7 posts views Thread by Nico | last post: by
41 posts views Thread by amygdala | last post: by
7 posts views Thread by pek | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.