473,691 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12012
*** 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
eddie12208
1 New Member
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
10178
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 to have the same session on the related domain. I bet the solution is really simple <grin>!... Kind Regards
8
12692
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 indexes. Here's the login script: <?php session_start(); // includes
3
2376
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 web-hotel When I run the same pages on my localhost, it can't find any sessions and I appear to not be logged In. I have tried to set my localhost on the "trusted sites" list and "always allow" in "override cookie handling" in my Explorer. But no luck....
5
673
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 web.config file is configured as such: <authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" name="myApplication"/> </authentication>
0
1336
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 stored in a mySQL database, and state is maintained through the URL, passing a session GUID in the URL between page calls. For example: http://localhost/index.html?-session=42FFA3821db04174BBRxjX1B4B48
1
5209
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 perfectly. However, when I refresh the page, new updated random number does not propagate to the image displayer script through sessions. The image displayer script continues showing the old number instead of the new random number. I checked the...
7
296
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" TYPE="TEXT"> <br>
41
3225
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 resolve this issue once and for all now. The problem might be PHP related but since I only develop applications using PHP, I'm not a hundred percent sure. Therefor I've taken the liberty to crosspost to comp.lang.php and alt.www.webmaster. I...
7
2382
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 mentioned already. You can point me to the post and I'll gladly read. I googled this a lot but, first, most people have tutorials for sharing sessions in subdomains, and, second, I have no clue what keywords to use. I am currently developing two web...
0
8599
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8533
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9079
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8951
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8791
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8795
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7624
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2966
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.