Re: session.bug_compat_42

From: Date: Tue, 23 Mar 2004 18:01:19 +0000
Subject: Re: session.bug_compat_42
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-181290@lists.php.net to get a copy of this message
James E Hicks III wrote:
What does the code look like that is causing this error? I know I can turn the error off but how do I fix the code that is causing it? 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 It only seems to appear when viewed using MSIE, Konqueror and Mozilla do not display this error, why? Here is some example code that I am using. <?php if (!session_is_registered('U_SI')) { #do some stuff. } session_register("last_time"); $last_time = time(); echo $_SESSION['last_time']; ?> Here are some settings from php.ini from the server that is giving the error. /etc/php4/php.ini register_globals = Off [Session] session.save_handler = files session.save_path = /tmp session.use_cookies = 1 session.name = PHPSESSID session.auto_start = 1 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.serialize_handler = php session.gc_probability = 1
session.gc_divisor     = 100
session.gc_maxlifetime = 1440 session.bug_compat_42 = 1 session.bug_compat_warn = 1 session.referer_check = session.entropy_length = 0 session.entropy_file = session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" PHP 4.3.2 (cli) (built: Aug 12 2003 14:25:22) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
    with Turck MMCache v2.3.20, Copyright (c) 2002-2003 TurckSoft, St. Petersburg, by Dmitry Stogov
James Hicks
It's complaining because you're registering "last_time" then using the global $last_time to set the value. You should be using $_SESSION['last_time'] = 'value'. In addition, you also don't need to use the session_ functions. All you need is $_SESSION. For session_is_registered() just use isset($_SESSION['key']). For session_register() use $_SESSION['key'] = 'value'. For session_unregister() use unset($_SESSION['key']). -- paperCrane <Justin Patrin>

« previous php.general (#181290) next »