473,791 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><ti tle>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="<?=$wwwro ot?>/userf/login.php">Logi n 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_st art 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_st art is
off)

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

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

Now with the newer PHP versions(that which comes with RH9 ) all this
works perfectly.
(Register globals is off and session.auto_st art 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_st art 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_V ARS[] 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
4412
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, but it does not happen with all versions of IE6. I've tested myself only with Mozilla and IE5, but the problem does not occur for me. I've got a username stored in $user, which is obtained from the $_POST variable, but after session_start() is...
27
7131
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 a user from information you got from the session. Each secure app on a site must challenge the user for name and password, each and every time the user accesses it (not just once and then store it in the session). If a secure app is multi-page,...
6
3435
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 to have the session_start(); at the top of the page as well. So when you have two things that need to be the first which do you put first? And if I put one before the other will that cause problems? Below is a copy of the php from my page. It...
1
2449
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 in groups and groups have roles). I have one script which is included in EVERY page in the protected area (masterFuncs.php) and it contains function declarations as well as the authentication module kick-off. Here is a snippet from masterFuncs...
1
1815
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 echo $var; ?> will the output be "test" or \"test\"?
2
1717
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 session.name = PHPSESSID session.auto_start = 1
2
2547
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 another page which fetches the variables from the session array and displays them. All works fine on the Linux test server. However the production server is Windoze running PHP 5. reg globals off I am intermittently losing variables. from the...
5
1604
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 session. When the customer send the data the following code will be run: if (isset($sendorder_x)) { session_start(); $nachricht = $bemerkungen; session_register(nachricht);
7
1646
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 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...
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.