473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 11921
*** 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave Mateer | last post by:
Hi Why does the following code allow me to keep the same session when in the same sub domain (ie admin.localhost), yet not when I goto another related domain eg main.localhost? I would like...
8
by: Steve Fitzgerald | last post by:
The below login script does work. The form does not seem to be submitting. I keep getting the username and password fields. The only errors I get are notices that email and password and undefined...
3
by: Simon K | last post by:
Hi I am working with sessions to check if the user is logged in. This usually works fine and all my .asp-pages checks if: <% session.Contents("loggedIn")=True %> But this only works on my...
5
by: Rob | last post by:
I have an ASP.NET application that uses forms-based authentication. A user wishes to be able to run multiple sessions of this application simultaneously from the user's client machine. The...
0
by: Jerad Rose | last post by:
I have an odd scenario. I am working on a hybrid site that uses various development platforms, namely traditional ASP and Lasso (a Mac scripting language). The site uses its own custom sessions...
1
by: Duncan | last post by:
I have a strange problem with sessions in PHP 5. I have a simple script that prints a random number both as a string and a picture on the screen. When I run the script for the first time, it works...
7
by: Nico | last post by:
Dear all, I made the following form. <FORM METHOD="POST" ACTION="prova.php"> <b>Combination</b><br><br> Element 1: <INPUT NAME="el1" TYPE="TEXT"> <BR> Element 2: <INPUT NAME="el2"...
41
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to...
7
by: pek | last post by:
OK, I've been having this problem for quite some time but never until now I really needed a solution. I have never thought of a work around, so I really need your help. Sorry if this has been...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.