chaiwei Posted September 15, 2009 Share Posted September 15, 2009 Hi I got this with this. Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0 Here is my script <?php session_start(); $_SESSION['a'] = $_POST['lala']; $a = 'abc'; ?> The $_POST['lala'] is not a defined variable; It is same as NULL, (will cause the warning appear also) How was it processing? Please advice? Quote Link to comment Share on other sites More sharing options...
Bricktop Posted September 15, 2009 Share Posted September 15, 2009 Hi chaiwei, It's probably because $_POST['lala'] contains no data. Does it still appear if $_POST['lala'] is not null? Quote Link to comment Share on other sites More sharing options...
chaiwei Posted September 15, 2009 Author Share Posted September 15, 2009 Yes, the $_POST['lala'] is a variable not yet defined. The warning will dissapear if I defined $_POST['lala'] equals to empty string $_POST['lala'] = ''; or anything else. Another thing I discover was it will be register global issues. My PHP version was 5.2.0 and register_global was turn off. You try run this script: 1. first step <?php session_start(); $_SESSION = array(); $a = 'I will be in session for the second time'; print_r($_SESSION); $_SESSION['a'] = $abc; ?> Array ( ) Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0 2. Remove the $_SESSION = array(); And refresh again. Then you will see Array ( [a] => I will be in session for the second time ) Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0 Quote Link to comment Share on other sites More sharing options...
gevensen Posted September 15, 2009 Share Posted September 15, 2009 you have to submit your post data no? if your passing along a post to another page it will pick it up but for example on the same page it would be if (isset($_POST['submit'])) { // if form has been submitted switch ($_POST['submit']) { case 'Submit': $_SESSION['lala']=$_POST['lala']; // the you can pass it along to the session break; case default: break; } } Quote Link to comment Share on other sites More sharing options...
gevensen Posted September 15, 2009 Share Posted September 15, 2009 you can also check to see if your post is set or not by <?php session_start(); if(isset($_POST['lala']) { $_SESSION['a'] = $_POST['lala']; $a = 'abc'; } else { echo "SESSION NOT SET!"; } ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 15, 2009 Share Posted September 15, 2009 Read the error message and do what it says - You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off Stop and start your web server to get any change made to the master php.ini to take effect and confirm that the settings were actually changed using a phpinof() statement in case the php.ini that you are changing is not the one that php is using. And yes, you should always make sure that your form was submitted before you access any of the form data, otherwise your code will not operate as expected. Quote Link to comment 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.