473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Session problems with register globals enabled

Hi,
i have a login script which makes use of sessions.

Login script
***********

session_start()
.....
.....
....
if(!empty($row["roll_no"]))
{
$_SESSION['bo_id']=$bo_id;
$_SESSION['pass']=$passw;
.....
.....

and sets the session varaibles if authentication is successful.

Then there is another script which is used to check if the user is
ADMIN
session_start();
.....
......

function isadmin()
{
if($_SESSION['bo_id'] != "ADMIN")
{
global $wwwroot;
include("style.html");
?>
<html><head><title>Must Be admin</title>
<meta http-equiv="Refresh"
content="5 ; URL=<?=$wwwroot?>/userf/login.php">
</head>
<br><br><center>
<font color="brown"><h4>Only Administerators Can Access
This Page</h4></font>
<br>You will be redirected to <a
href="<?=$wwwroot?>/userf/login.php">Login Page</a> in 5 seconds
</center></body></html>

<?
exit;
}
}
Now with the newer PHP versions(that which comes with RH9 ) all this
works perfectly.
(Register globals is off and session.auto_start is 1 )
But with older PHP versions 4.1.2 etc this script doesn't work because
$_SESSION['bo_id'] is empty in the admin authentication script(2nd
script).
But this session variable is set in the login script !!
(In old PHP versions register globals is on and session_auto_start is
off)

Can anyone plz tell me how to make this work in all PHP versions!!

Thanx
Manu
Jul 17 '05 #1
1 4561
<snip>

Now with the newer PHP versions(that which comes with RH9 ) all this
works perfectly.
(Register globals is off and session.auto_start is 1 )
But with older PHP versions 4.1.2 etc this script doesn't work because
$_SESSION['bo_id'] is empty in the admin authentication script(2nd
script).
But this session variable is set in the login script !!
(In old PHP versions register globals is on and session_auto_start is
off)

Can anyone plz tell me how to make this work in all PHP versions!!

Thanx
Manu


Hi Manu,

That is probably because $_SESSION[] array is new. So in your older versions
of PHP you just create the $_SESSION-array and store something in it.
That is why your other script cannot retrieve values from it because it
simply isn't there. (It is destroyed as the script ends)

You can always use $HTTP_SESSION_VARS[] to get/set values in your session,
allthough it is not superglobal as $_SESSION is.

So you should make it global if you cannot reach it somewhere (function).

Hope this helps.

Regards,
Erwin Moller
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Daniel Bengs | last post by:
Hi there... I've got a problem where a normal string variable loses its value after session_start() is called. The funny thing is, that this only happens for some people, and they are using IE6,...
27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
6
by: John | last post by:
Hi. I am having a few header problems at the moment with a login page. I don't have my headers at the top of the page where I've learned I need to have them. However, I also know I'm supposed...
1
by: Sean Pinto | last post by:
Ok, you all are going to have to bear with me on this one as it is kinda complicated to explain. I am implementing a company management suite that requires Role-Based authentiations (ie. users are...
1
by: yawnmoth | last post by:
even though register globals is disabled by default, i'm currious as to how it and magic quotes interact. consider the following code: <? // assuming $_GET='"test"' and register globals enabled...
2
by: danielTI | last post by:
hi all, I am using Ubuntu hoary, kernel 2.6.10-5-386, apache 2, php 4 with th efollowing configuraton: session.save_handler = files session.save_path = /tmp session.use_cookies = 1...
2
by: Geoff Berrow | last post by:
I have a page containing a form. The page submits to itself and if the data validates, stores the posted variables into a database and also into a session. I then use header to redirect to...
5
by: Baeribeeri | last post by:
I am writing a foto upload site. A PHP page displays the uploades fotos an the customer can choose several things. The data of the fotos are kept in an array called bilder. I keep the data in a...
7
by: Erwin Moller | last post by:
Hi group, Does anybody know what causes the following Warning? __________________________________________________ Warning: Unknown(): Your script possibly relies on a session side-effect...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.