lapfama Posted June 20, 2008 Share Posted June 20, 2008 Hello, I'm having a real tough time with session variables. The values don't pass from one page to the next one. Even with a very simple code like this one: Page#1 <?php session_start(); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $_SESSION['FName']="Jay"; $_SESSION['LName']="Pay"; echo "<a href='session2.php'>Try now</a>"; ?> </body> </html> Page#2 <?php session_start(); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php echo "My name is ".$_SESSION['FName']. " ". $_SESSION['LName'] ; ?> </body> </html> Thanks in advance for your comments. Laura Link to comment https://forums.phpfreaks.com/topic/111129-_session/ Share on other sites More sharing options...
MadTechie Posted June 20, 2008 Share Posted June 20, 2008 Works fine for me.. not a scripting problem Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570305 Share on other sites More sharing options...
mark110384 Posted June 20, 2008 Share Posted June 20, 2008 Try lookinging at session_register Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570307 Share on other sites More sharing options...
jonsjava Posted June 20, 2008 Share Posted June 20, 2008 same here. Do you have cookies disabled on your browser? Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570309 Share on other sites More sharing options...
lemmin Posted June 20, 2008 Share Posted June 20, 2008 Your web server might not have access to the default session folder. Try adding the line: session_save_path("sessions/"); to make the session folder local to the server. (You probably have to make the folder that you specify.) Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570312 Share on other sites More sharing options...
PFMaBiSmAd Posted June 20, 2008 Share Posted June 20, 2008 Add the following two lines after your first opening <?php tag on both pages - ini_set ("display_errors", "1"); error_reporting(E_ALL); @mark110384, session_register was depreciated long ago in 2002, it only works when register_globals are on, and it, along with register_globals, have been completely removed in php6. Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570326 Share on other sites More sharing options...
lapfama Posted June 20, 2008 Author Share Posted June 20, 2008 Thanks, But no errors reported Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570333 Share on other sites More sharing options...
lapfama Posted June 20, 2008 Author Share Posted June 20, 2008 I read that "session_register" is deprecated. Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570338 Share on other sites More sharing options...
PFMaBiSmAd Posted June 20, 2008 Share Posted June 20, 2008 If the posted code does not work, either the php code is not being parsed/executed or your browser is not accepting the session id cookie. Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570414 Share on other sites More sharing options...
corbin Posted June 20, 2008 Share Posted June 20, 2008 It might not like that because of the outputting before sending headers.... If output buffering isn't on, try the following. (Although, if this is the case, PFMaBiSmAd's code should've made it show.... Oh wait! Try changing "ini_set ("display_errors", "1");" to "ini_set ("display_errors", "on");") Anyway, try the following: <?php session_start(); $_SESSION['FName']="Jay"; $_SESSION['LName']="Pay"; ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <a href="session2.php">Try now</a> </body> </html> Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570426 Share on other sites More sharing options...
lapfama Posted June 20, 2008 Author Share Posted June 20, 2008 Thanks to everyone that try to contribute. And special thanks to PFMaBiSmAd. His comment "either the php code is not being parsed/executed" turned on the light. I contacted my web host, and the problem was that the path for the PHP Scripting needed to be upddated. Thanks again, Laura Link to comment https://forums.phpfreaks.com/topic/111129-_session/#findComment-570450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.