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!
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
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]
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.
<?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>';
?>
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?
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.
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.
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.
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.