kingtheoden Posted December 21, 2007 Share Posted December 21, 2007 Running Apache 2.2 and PHP 5.2 on XP Professional, when I check my PHP info page, it says that sessions are enabled. When I attempt to trigger a session, a cookie is generated in my temp folder. However, in my tutorial the page does not call the cookie apparently and the proper event is not triggered. Is there any possible program that could be running in the background to prevent this? I know my code is correct because I tested it on my remote server and it functions perfectly. On my secondary local server computer, the code also works. Quote Link to comment https://forums.phpfreaks.com/topic/82683-solved-sessions-running-but-not-functioning-background-program-blocking/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 21, 2007 Share Posted December 21, 2007 Post your code, it is probably doing something not recommended like relying on register globals. Also, check your web server log for errors. Quote Link to comment https://forums.phpfreaks.com/topic/82683-solved-sessions-running-but-not-functioning-background-program-blocking/#findComment-420542 Share on other sites More sharing options...
revraz Posted December 21, 2007 Share Posted December 21, 2007 Are we talking Sessions or Cookies? Quote Link to comment https://forums.phpfreaks.com/topic/82683-solved-sessions-running-but-not-functioning-background-program-blocking/#findComment-420580 Share on other sites More sharing options...
kingtheoden Posted December 21, 2007 Author Share Posted December 21, 2007 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Session</title> </head> <body> <form action="session2.php" method="post" name="form1" id="form1"> <label for="name">Name</label> <input type="text" name="name" id="name" /> <input name="Submit" type="submit" value="Submit" /> </form> </body> </html> <?php // initiate session session_start(); // check that form has been submitted and that name is not empty if ($_POST && !empty($_POST['name'])) { // set session variable $_SESSION['name'] = $_POST['name']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Session Test 2</title> </head> <body> <?php // check session variable is set if (isset($_SESSION['name'])) { // if set, greet by name echo 'Hello, '.$_SESSION['name'].'. <a href="session3.php">Next</a>'; } else { // if not set, send back to login echo 'Who are you? <a href="session1.php">Login</a>'; } ?> </body> </html> <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Session Test 3</title> </head> <body> <?php // check whether session variable is set if (isset($_SESSION['name'])) { // if set, greet by name echo 'Hi, '.$_SESSION['name'].'. See, I remembered your name!<br />'; // unset session variable unset($_SESSION['name']); // end session session_destroy(); echo '<a href="session2.php">Page 2</a>'; } else { // display if not recognized echo 'Sorry, I don\'t know you.<br />'; echo '<a href="session1.php">Login</a>'; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/82683-solved-sessions-running-but-not-functioning-background-program-blocking/#findComment-420854 Share on other sites More sharing options...
kingtheoden Posted December 21, 2007 Author Share Posted December 21, 2007 When I say 'sessions are not working' I should be more specific. In the above examples, a cookie is properly generated; a second blank one is also properly generated in the temp folder after the session is destroyed. The crux of the mystery is that on my browsers, the statement triggered by $_SESSION['name'] does not occur. Instead, I see the else statement printed. I don't want to do this, but it looks like I'm out of options: time to reinstall PHP... Quote Link to comment https://forums.phpfreaks.com/topic/82683-solved-sessions-running-but-not-functioning-background-program-blocking/#findComment-420881 Share on other sites More sharing options...
kingtheoden Posted December 21, 2007 Author Share Posted December 21, 2007 It seems there was a bad file or folder somewhere. After the reinstall, it is working fine! Quote Link to comment https://forums.phpfreaks.com/topic/82683-solved-sessions-running-but-not-functioning-background-program-blocking/#findComment-420901 Share on other sites More sharing options...
revraz Posted December 22, 2007 Share Posted December 22, 2007 I bet your session save path was incorrect in your php.ini Quote Link to comment https://forums.phpfreaks.com/topic/82683-solved-sessions-running-but-not-functioning-background-program-blocking/#findComment-420938 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.