Page 1 of 1
Session Help
Posted: Fri Aug 04, 2006 1:06 pm
by southpaw17er
Everah | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi all,
I've recently installed Apache 2, mysql, and PHP 5 on a Windows XP machine. All is working well except for sessions in php. I've tried everything I can think of and have reduced a test page to this:
PAGE 1 - test.php
Code: Select all
<?php
session_start();
$_SESSION['test'] = 'hello';
echo $_SESSION['test'];
?>
<a href="test2.php">click me</a>
PAGE 2 - test2.php
Code: Select all
<?php
session_start();
echo $_SESSION['test'];
?>
Hello gets displayed on page 1, but not page two. Could my ini file be configured incorrectly? Thanks in advance for any help.
Everah | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Fri Aug 04, 2006 1:33 pm
by RobertGonzalez
Have you cleared your browser cache? Start with that and see if it helps.
Posted: Fri Aug 04, 2006 3:55 pm
by southpaw17er
Thanks for the help, I cleared my cache, and still got nothing. I've tried restarting my browser, using both Firefox and IE, and restarting Windows, but I still get nothing.
Any Ideas?
Thanks again
Posted: Fri Aug 04, 2006 4:39 pm
by RobertGonzalez
Try this...
test1.php
Code: Select all
<?php
session_start();
echo session_id();
$_SESSION['test'] = 'hello';
echo $_SESSION['test'];
echo '<pre>' . print_r($_SESSION) . '</pre>';
echo '<br /><br /><a href="test2.php">Click me to go to page 2</a>';
?>
test2.php
Code: Select all
<?php
session_start();
if (isset($_SESSION['test']))
{
echo $_SESSION['test'];
}
else
{
echo '<pre>' . print_r($_SESSION) . '</pre>';
}
echo '<br /><br /><a href="test1.php">Click me to go to back to page 1</a>';
?>
Posted: Fri Aug 04, 2006 8:06 pm
by southpaw17er
Everah:
I tried that code and received this output for test.php,
fo2abdb7vpan29dv79c2o8ja73helloArray ( [test] => hello )
1
And for test2.php, only
Array ( )
1
So it still appears that it's not working.
Thanks again for your help.
Posted: Fri Aug 04, 2006 8:40 pm
by RobertGonzalez
Have you searched these boards for 'session not working'? I vaguely recall something similar to this being posted by another poster a few months ago. I forget what the resolution was, but I think he got it resolved.
Is this happening on a hosted server or a local server? Do you have access to the sessions data folder that PHP uses for storing session data?
Posted: Sat Aug 05, 2006 12:17 pm
by southpaw17er
I searched through a few dozen posts similar to mine, but the only problem that seemed logically to fit with my situation is when a firewall was restricting use of sessions. I tried it with my firewall off, but it still does not work.
Also, this is happening on a local windows xp machine. There is a sessiondata folder in c:/php, but my php.ini file is set to put session data in c:/temp. However, both of those are empty, so it appears not to be recording anything.
Thanks
Posted: Sat Aug 05, 2006 5:17 pm
by RobertGonzalez
What are the permissions on the sessiondata folders (both in /php and in /temp)?
Posted: Mon Aug 07, 2006 11:48 am
by southpaw17er
Both folders had read-only checked under attributes in properties. I unchecked both and still no session variables would pass. Also, when I go back and look at properties, a square box is in the read-only box, whether I left it checked or unchecked.
Thanks
Posted: Mon Aug 07, 2006 11:59 am
by feyd
Is the server running under a different user? It's normal for the server to run under a different user than the one you're logged in as. Make sure that user has permission to write in those directories.
Posted: Mon Aug 07, 2006 12:19 pm
by southpaw17er
I only have one user account on this computer, the administrator account. So I assume the server must be running on this same account.
Thanks
Posted: Mon Aug 07, 2006 12:21 pm
by feyd
There are a lot more accounts than those you can see in the User Accounts panel. For instance, there's the SYSTEM account, the SERVICE account, and so forth.
Posted: Mon Aug 07, 2006 1:04 pm
by southpaw17er
So how would I determine which of these accounts my server is running off of?
Posted: Mon Aug 07, 2006 2:34 pm
by volka
Does
say something about
USERPROFILE? And is it <whatever>\LocalService ?
Posted: Mon Aug 07, 2006 6:04 pm
by southpaw17er
volka:
Yes, under USERPROFILE is C:\Documents and Settings\LocalService
Is this how it should be?
Thanks