Page 1 of 1

session warning in php 5

Posted: Fri Sep 22, 2006 3:40 pm
by emmbec
Hi, I am getting this warning when I run a page that uses sessions:
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
Has anyone had this problem? How did you solve it?
Changing the settings of the php.ini file is not an option since I don't have access to that file, is there a way around this problem?

This is sort of the code I'm using:

Code: Select all

<?php
session_start();
$var= "my string ";
session_register("var");

if(isset($_SESSION["var"])){
	$var=$_SESSION["var"];
}
.
.
.

Posted: Fri Sep 22, 2006 4:02 pm
by feyd
lose session_register().

Posted: Fri Sep 22, 2006 4:15 pm
by gkwhitworth
yeah listen to feyd...loose the session_register.

Note to feyd:

see this is why we need a session tut.

--
Greg

Posted: Fri Sep 22, 2006 4:36 pm
by AKA Panama Jack
Yeah, session_register is kind of redundant and useless under PHP 4/5.

You should just assigned the session variable as you would any variable.

Code: Select all

<?php 
session_start(); 
$var= "my string "; 
$_SESSION["var"] = $var;

if(isset($_SESSION["var"])){ 
        $var=$_SESSION["var"]; 
}
?>

Posted: Sat Sep 23, 2006 12:04 am
by aaronhall
gkwhitworth wrote:yeah listen to feyd...loose the session_register.

Note to feyd:

see this is why we need a session tut.

--
Greg
http://www.google.com/search?hl=en&q=ph ... n+tutorial

Posted: Sat Sep 23, 2006 2:25 am
by gkwhitworth
aaron wrote:
I know that their are tuts out there, there are tuts out there for everything. I just thought we should have one right here. I mean, why do we even have a tutorial section then if we have google. Please don't take this offensively, I am just saying......if you take a poll of what a new user usually wants to accomplish it requires the power of the global $_SESSION. I have only been at this forum a short time and have seen numerous $_SESSION topics, that is why I think it would be wise to have a session tut.

--

Greg