Session Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
partiallynothing
Forum Commoner
Posts: 61
Joined: Fri Nov 21, 2003 5:02 pm
Location: connecticut, usa

Session Problem

Post by partiallynothing »

I really didn't know where to put this so hopefully this section works.

Anyway, I have been having a problem recently. I have Windows XP Pro, IIS 5 (I believe; whatever comes on Windows XP), newest stable version of both PHP and MySQL. When I view a page on my computer (localhost) the session don't work. The session variables are not carried over from the last page. Do I have a setting wrong? Is this a known problem.

I really am in a bind so anything would be helpful. Thanks!
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

Do you have session_start(); at the top of every page?

Like this:

Code: Select all

<?php
session_start();
//rest of the code for that page
?>
If you do, and it's still not working, post some code, there could be other problems.
User avatar
partiallynothing
Forum Commoner
Posts: 61
Joined: Fri Nov 21, 2003 5:02 pm
Location: connecticut, usa

Post by partiallynothing »

See, the weird thing is it works fine on my site (hosted by nexpoint), just not locally. Is there anything in the configuration front that may be wrong?
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

in the php.ini you can configure it to auto start sessions. maybe that's not on on your local box.
User avatar
dyconsulting
Forum Newbie
Posts: 14
Joined: Mon Dec 01, 2003 6:52 pm
Location: San Francisco

session.save_path is missing from php.ini

Post by dyconsulting »

You are missing a directory where session info is stored. PHP will not create this directory structure automatically.

Your code is fine. All you have to do is open php.ini file and look for :
session.save_path. Change it to session.save_path=C:\PHP\sessiondata (provided you have created that folder first).
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: session.save_path is missing from php.ini

Post by JAM »

dyconsulting wrote:You are missing a directory where session info is stored. PHP will not create this directory structure automatically.

Your code is fine. All you have to do is open php.ini file and look for :
session.save_path. Change it to session.save_path=C:\PHP\sessiondata (provided you have created that folder first).
Just wondering how you know that from the post above.

@partiallynothing:
"It doesn't work"; There can be 1-100's of reason for this. Could you paste error-messages (if any) and perhaps some code? Bump up the error level on yo localhost to E_ALL (max) just to be sure that you know that you are not supressing any errors generated...
User avatar
dyconsulting
Forum Newbie
Posts: 14
Joined: Mon Dec 01, 2003 6:52 pm
Location: San Francisco

Post by dyconsulting »

Simple Watson:
He said that his code works in production. So this must be configuration issue on dev box. By default php install will not create session directory. Without this folder there is no way to store session data and this is why code breaks.
Post Reply