v4g Posted January 4, 2007 Share Posted January 4, 2007 Hello,I use $_SESSION['rand_code'] variable in order to pass the image validator info to the page where the form is and compare it with the data the user submits. The problem is that $_SESSION var arrives empty.// [b]form.php[/b] (submits to itself to check)session_name('name');session_start();.....[b] // if i echo $_SESSION['rand_code'] here even after the form has submited and the image was created, it's null[/b]if (!isset($_POST['validator']) || ($_POST['validator'] != $_SESSION['rand_code'])) //$_POST['validator']: form text field data { <error flag and echo form> ... <img src='random.php' alt='validator' width='60' height='20' vspace='1' align='top'>) ...}else { <do database stuff>}....// [b]random.php[/b]session_name('name');session_start();...$_SESSION['rand_code']= <the random number of the image>..Its strange because this script used to work until recently. The only change that I did was to turn registers global off. My [b]php.ini[/b] is:register_globals = Offsession.cookie_lifetime = 1 [Zend]zend_optimizer.optimization_level=15zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-2.5.10zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-2.5.10zend_optimizer.version=2.5.10azend_extension = /usr/local/lib/ioncube_loader_lin_4.4.sozend_extension=/usr/local/Zend/lib/ZendExtensionManager.sozend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.soPlease help, thanks for reading. Link to comment https://forums.phpfreaks.com/topic/32847-_session-returns-empty-on-other-pages/ Share on other sites More sharing options...
metrostars Posted January 4, 2007 Share Posted January 4, 2007 Did you remember to put session_start() on the file where the session as created as well? Link to comment https://forums.phpfreaks.com/topic/32847-_session-returns-empty-on-other-pages/#findComment-152890 Share on other sites More sharing options...
v4g Posted January 4, 2007 Author Share Posted January 4, 2007 [quote author=metrostars link=topic=120989.msg496804#msg496804 date=1167918456]Did you remember to put session_start() on the file where the session as created as well?[/quote]YEs session_start() is on all pages. Link to comment https://forums.phpfreaks.com/topic/32847-_session-returns-empty-on-other-pages/#findComment-152891 Share on other sites More sharing options...
metrostars Posted January 4, 2007 Share Posted January 4, 2007 What did you use to set the varibles in the first place?Was it just $_SESSIon['rand_code'] = blah ? Link to comment https://forums.phpfreaks.com/topic/32847-_session-returns-empty-on-other-pages/#findComment-152919 Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2007 Share Posted January 4, 2007 The amount of your code that you posted does not give enough information about what might be going on (you won't believe the number of times on Forums where some code was left out as being irrelevant to the problem which was actually where the problem was.)Since you are already using $_SESSION variables, changing register_globals should have had no effect on the function of sessions, but it may have had an effect on other code involved (such as generating the random value and setting the session variable.) We cannot tell this until we can see the actual code.Also, add the following line after your first opening <?php tag -[code]error_reporting(E_ALL);[/code] Link to comment https://forums.phpfreaks.com/topic/32847-_session-returns-empty-on-other-pages/#findComment-152940 Share on other sites More sharing options...
v4g Posted January 6, 2007 Author Share Posted January 6, 2007 [b]SOLVED[/b]When I deleted the php.ini that was in the public_html/test/ everything went back to normal!Now I have only one php.ini in the public_html/ Link to comment https://forums.phpfreaks.com/topic/32847-_session-returns-empty-on-other-pages/#findComment-154223 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Share Posted January 16, 2007 I'm having this same problem. My register_globals is set to On.I am setting a session variable and if I echo it immediately it works fine. If I try to echo it on another page it doesn't display anything.code:session_start();$_SESSION['var1'] = 123;$_SESSION['var2'] = 456;print_r($_SESSION); Link to comment https://forums.phpfreaks.com/topic/32847-_session-returns-empty-on-other-pages/#findComment-161750 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Share Posted January 16, 2007 If I go to another page and useprint_r($_SESSION)orecho ($_SESSION['var1'];nothing displays Link to comment https://forums.phpfreaks.com/topic/32847-_session-returns-empty-on-other-pages/#findComment-161757 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.