Suchy Posted April 17, 2008 Share Posted April 17, 2008 I am having problem with sessions in PHP 5.2.3 I am getting: 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 How can I get sessions to work ? Everything else is as expected. Quote Link to comment Share on other sites More sharing options...
ucffool Posted April 17, 2008 Share Posted April 17, 2008 Your code is using globals, which are turned off. your script is the issue, not sessions in php5. we would need to see that to even begin to help. Quote Link to comment Share on other sites More sharing options...
Suchy Posted April 22, 2008 Author Share Posted April 22, 2008 Even simple script like this gives me that error (it works on php 4.4.7) <?php session_start(); $counter++; print ($counter); session_register("counter"); ?> Here is some more info: Session Support enabled Registered save handlers files user sqlite Registered serializer handlers php php_binary [table] [tr][td]Directive Local Value Master Value session.auto_startOffOff session.bug_compat_42OnOn session.bug_compat_warnOnOn session.cache_expire180180 session.cache_limiternocachenocache session.cookie_domainno valueno value session.cookie_httponlyOffOff session.cookie_lifetime00 session.cookie_path// session.cookie_secureOffOff session.entropy_fileno valueno value session.entropy_length00 session.gc_divisor100100 session.gc_maxlifetime14401440 session.gc_probability11 session.hash_bits_per_character44 session.hash_function00 session.namePHPSESSIDPHPSESSID session.referer_checkno valueno value session.save_handlerfilesfiles session.save_pathno valueno value session.serialize_handlerphpphp session.use_cookiesOnOn session.use_only_cookiesOffOff session.use_trans_sid00 Quote Link to comment Share on other sites More sharing options...
ucffool Posted April 22, 2008 Share Posted April 22, 2008 It all has to do with the PHP.ini configuration file. From the PHP manual: If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled. Note: register_globals: important noteAs of PHP 4.2.0, the default value for the PHP directive register_globals is off, and it was completely removed as of PHP 6.0.0. The PHP community discourages developers from relying on this directive, and encouragees the use of other means, such as the superglobals. So your code should be written as follows: <?php session_start(); $counter++; print ($counter); $_SESSION['counter'] = $counter; ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 22, 2008 Share Posted April 22, 2008 You have two problems, the code is dependent on register globals being on, but they are not (and you must rewrite your code to eliminate the use of the session_register() function) and for help with the specific error message, read my post in this link - http://www.phpfreaks.com/forums/index.php/topic,193575.msg870830.html#msg870830 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.