session warning in php 5

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

session warning in php 5

Post 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"];
}
.
.
.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

lose session_register().
User avatar
gkwhitworth
Forum Commoner
Posts: 85
Joined: Tue Sep 05, 2006 8:28 pm
Location: Wasilla, Alaska

Post by gkwhitworth »

yeah listen to feyd...loose the session_register.

Note to feyd:

see this is why we need a session tut.

--
Greg
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post 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"]; 
}
?>
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post 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
User avatar
gkwhitworth
Forum Commoner
Posts: 85
Joined: Tue Sep 05, 2006 8:28 pm
Location: Wasilla, Alaska

Post 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
Post Reply