mganesh Posted May 29, 2006 Share Posted May 29, 2006 Here is a peculiar problem that I am encounteringThis problem is ONLY IN FIREFOX and NOT IN IE (Important !)I have two pages page1.php, page2.phpHere are the exerpts from the two files.[b]page1.php :[/b]session_start();session_register("username_session");session_register("fullname_session");$_SESSION["username_session"]=<value from database>$_SESSION["fullname_session"]=<value from database>There is also a form for uploading 5 files (MAX_FILE_SIZE is mentioned as a hidden field with 1000000 as the value)[b]page2.php :[/b]session_start();echo $_SESSION["username_session"]."<BR>";echo $_SESSION["fullname_session"];echo $_SESSION["session_variable_created_in_earlier_page"];The file info posted from the previous page is available here, and also the session variable created on another previous page, but not the session variables created and assigned in page1.php.The observation: Session variables created on the same page where a file upload form resides, vanish in the next page. This is observed only in firefox and not internet explorer. In IE everything is just fine.Has any one come across this problem ? Quote Link to comment https://forums.phpfreaks.com/topic/10688-file-upload-and-session-variables-problem/ Share on other sites More sharing options...
glenelkins Posted May 29, 2006 Share Posted May 29, 2006 i suppose it all depends on where your session_start(); is in each file.You cannot access $_SESSION[] from inside seperate <?php ?> tags. For example:<?php session_start(); $_SESSION['name'] = 'bob'; echo $_SESSION['name']; <--- WILL DISPLAY?><?php echo $_SESSION['name']; <--- WILL NOT DISPLAY?>As you can see, you cannot take the value of $_SESSION['name'] in the second section as session_start() is not in the same <?php ?> as the echo command.I hope this makes sense Quote Link to comment https://forums.phpfreaks.com/topic/10688-file-upload-and-session-variables-problem/#findComment-39907 Share on other sites More sharing options...
Ferenc Posted May 29, 2006 Share Posted May 29, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?phpsession_start();$_SESSION['name'] = 'bob';echo $_SESSION['name']; //<--- WILL DISPLAY?><?phpecho $_SESSION['name']; //<--- WILL NOT DISPLAY?>[/quote]You are wrong, the code above displayed bobbob for me, both locally and remotely(IE and firefox).If what you said was true, why even have sessions?The key to sessions is to start them correctly on every page. Most people with session issues fail to do that. Quote Link to comment https://forums.phpfreaks.com/topic/10688-file-upload-and-session-variables-problem/#findComment-40011 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.