473,405 Members | 2,176 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,405 software developers and data experts.

Losing session variables value

I have a case where the session values appear to lose their value. I
tracked it down with some print_r inserted. Here are the lines:

print '<br 1: '; print_r($_SESSION);
$adminLevel = $_POST['edit_level_list'];
print '<br 2: '; print_r($_SESSION);

Here is the output:

1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
2: Array ( [adminLevel] =[clientID] =0 )

There is nothing special about the variable$adminlevel. It is just an
ordinary local variable. Field edit_level_list is a select list.

If I change the name of the variable from $adminLevel to $foo, then the
session variable does not lose its value.

If I then immediately set $adminLevel = $foo, the session variable loses
its value.

What is so special about the name of a local variable?
Aug 21 '08 #1
8 1758
sheldonlg wrote:
I have a case where the session values appear to lose their value. I
tracked it down with some print_r inserted. Here are the lines:

print '<br 1: '; print_r($_SESSION);
$adminLevel = $_POST['edit_level_list'];
print '<br 2: '; print_r($_SESSION);

Here is the output:

1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
2: Array ( [adminLevel] =[clientID] =0 )

There is nothing special about the variable$adminlevel. It is just an
ordinary local variable. Field edit_level_list is a select list.

If I change the name of the variable from $adminLevel to $foo, then the
session variable does not lose its value.

If I then immediately set $adminLevel = $foo, the session variable loses
its value.

What is so special about the name of a local variable?
You probably have register_globals set to on - which is should NOT be.
Turn it off.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 22 '08 #2
sheldonlg wrote:
I have a case where the session values appear to lose their value. I
tracked it down with some print_r inserted. Here are the lines:

print '<br 1: '; print_r($_SESSION);
$adminLevel = $_POST['edit_level_list'];
print '<br 2: '; print_r($_SESSION);

Here is the output:

1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
2: Array ( [adminLevel] =[clientID] =0 )

There is nothing special about the variable$adminlevel. It is just an
ordinary local variable. Field edit_level_list is a select list.

If I change the name of the variable from $adminLevel to $foo, then the
session variable does not lose its value.

If I then immediately set $adminLevel = $foo, the session variable loses
its value.

What is so special about the name of a local variable?
Can you reproduce the bug by doing something like:

-----%<----- foo.php ----------------------------------------
<?php
$_SESSION=array('adminLevel' ='SUPERUSER', 'clientID' =0);
$_POST['edit_level_list'] = 'foo';
print '<br 1: '; print_r($_SESSION);
$adminLevel = $_POST['edit_level_list'];
print '<br 2: '; print_r($_SESSION);
?>
-----%<----- foo.php ----------------------------------------

$ php foo.php

BTW, what does php -i show as your PHP version. Mine's 5.2.5.

Best regards,

--
Charles
Aug 22 '08 #3
Jerry Stuckle wrote:
sheldonlg wrote:
>I have a case where the session values appear to lose their value. I
tracked it down with some print_r inserted. Here are the lines:

print '<br 1: '; print_r($_SESSION);
$adminLevel = $_POST['edit_level_list'];
print '<br 2: '; print_r($_SESSION);

Here is the output:

1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
2: Array ( [adminLevel] =[clientID] =0 )

There is nothing special about the variable$adminlevel. It is just an
ordinary local variable. Field edit_level_list is a select list.

If I change the name of the variable from $adminLevel to $foo, then
the session variable does not lose its value.

If I then immediately set $adminLevel = $foo, the session variable
loses its value.

What is so special about the name of a local variable?

You probably have register_globals set to on - which is should NOT be.
Turn it off.
I don't -- unless the hosting company has that by default somehow. I
never do anything with register_globals.
Aug 22 '08 #4

sheldonlg schreef:
Jerry Stuckle wrote:
>sheldonlg wrote:
>>I have a case where the session values appear to lose their value. I
tracked it down with some print_r inserted. Here are the lines:

print '<br 1: '; print_r($_SESSION);
$adminLevel = $_POST['edit_level_list'];
print '<br 2: '; print_r($_SESSION);

Here is the output:

1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
2: Array ( [adminLevel] =[clientID] =0 )

There is nothing special about the variable$adminlevel. It is just
an ordinary local variable. Field edit_level_list is a select list.

If I change the name of the variable from $adminLevel to $foo, then
the session variable does not lose its value.

If I then immediately set $adminLevel = $foo, the session variable
loses its value.

What is so special about the name of a local variable?

You probably have register_globals set to on - which is should NOT be.
Turn it off.

I don't -- unless the hosting company has that by default somehow. I
never do anything with register_globals.
DOn't guess, check. :-)

Make a file with only:
<?php
phpinfo();
?>

And see what it says.

Regards,
Erwin Moller
--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================
Aug 22 '08 #5
Erwin Moller wrote:
>
sheldonlg schreef:
>Jerry Stuckle wrote:
>>sheldonlg wrote:
I have a case where the session values appear to lose their value.
I tracked it down with some print_r inserted. Here are the lines:

print '<br 1: '; print_r($_SESSION);
$adminLevel = $_POST['edit_level_list'];
print '<br 2: '; print_r($_SESSION);

Here is the output:

1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
2: Array ( [adminLevel] =[clientID] =0 )

There is nothing special about the variable$adminlevel. It is just
an ordinary local variable. Field edit_level_list is a select list.

If I change the name of the variable from $adminLevel to $foo, then
the session variable does not lose its value.

If I then immediately set $adminLevel = $foo, the session variable
loses its value.

What is so special about the name of a local variable?
You probably have register_globals set to on - which is should NOT
be. Turn it off.

I don't -- unless the hosting company has that by default somehow. I
never do anything with register_globals.

DOn't guess, check. :-)

Make a file with only:
<?php
phpinfo();
?>

And see what it says.
Did that last night. See my previous reply.
Aug 22 '08 #6

sheldonlg schreef:
Erwin Moller wrote:
>>
sheldonlg schreef:
>>Jerry Stuckle wrote:
sheldonlg wrote:
I have a case where the session values appear to lose their value.
I tracked it down with some print_r inserted. Here are the lines:
>
print '<br 1: '; print_r($_SESSION);
$adminLevel = $_POST['edit_level_list'];
print '<br 2: '; print_r($_SESSION);
>
Here is the output:
>
1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
2: Array ( [adminLevel] =[clientID] =0 )
>
There is nothing special about the variable$adminlevel. It is just
an ordinary local variable. Field edit_level_list is a select list.
>
If I change the name of the variable from $adminLevel to $foo, then
the session variable does not lose its value.
>
If I then immediately set $adminLevel = $foo, the session variable
loses its value.
>
What is so special about the name of a local variable?
>

You probably have register_globals set to on - which is should NOT
be. Turn it off.
I don't -- unless the hosting company has that by default somehow. I
never do anything with register_globals.

DOn't guess, check. :-)

Make a file with only:
<?php
phpinfo();
?>

And see what it says.

Did that last night. See my previous reply.
Hi,

I don't see any previous reply where you said you did it.
Did you start posting via googlegroups maybe, halfway the thread?
(If so, I have dropped that response, see my sig. Sorry)

Regards,
Erwin Moller

--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================
Aug 22 '08 #7
Erwin Moller wrote:
>
sheldonlg schreef:
>Erwin Moller wrote:
>>>
sheldonlg schreef:
Jerry Stuckle wrote:
sheldonlg wrote:
>I have a case where the session values appear to lose their
>value. I tracked it down with some print_r inserted. Here are
>the lines:
>>
>print '<br 1: '; print_r($_SESSION);
>$adminLevel = $_POST['edit_level_list'];
>print '<br 2: '; print_r($_SESSION);
>>
>Here is the output:
>>
>1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
>2: Array ( [adminLevel] =[clientID] =0 )
>>
>There is nothing special about the variable$adminlevel. It is
>just an ordinary local variable. Field edit_level_list is a
>select list.
>>
>If I change the name of the variable from $adminLevel to $foo,
>then the session variable does not lose its value.
>>
>If I then immediately set $adminLevel = $foo, the session variable
>loses its value.
>>
>What is so special about the name of a local variable?
>>
>
You probably have register_globals set to on - which is should NOT
be. Turn it off.
>

I don't -- unless the hosting company has that by default somehow.
I never do anything with register_globals.

DOn't guess, check. :-)

Make a file with only:
<?php
phpinfo();
?>

And see what it says.

Did that last night. See my previous reply.

Hi,

I don't see any previous reply where you said you did it.
Did you start posting via googlegroups maybe, halfway the thread?
(If so, I have dropped that response, see my sig. Sorry)

Regards,
Erwin Moller
You didn't because it got stuck in my emailer outbox for some reason. I
must have had a connection failure and didn't notice it as I left the
computer to go to sleep. Here it is:

====
I just did a phpinfo. It showed that register_globals is, indeed, on.
By default it is set to off as of PHP4.2 and the version I am running is
5.2.6. The hosting company must have turned it on. Unfortunately,
according to the manual:

"Please note that register_globals cannot be set at runtime
(ini_set()). Although, you can use .htaccess if your host allows it as
described above. An example .htaccess entry: php_flag register_globals
off ."

I will have to check to see if I can have a .htaccess file.
====
Aug 22 '08 #8

sheldonlg schreef:
Erwin Moller wrote:
>>
sheldonlg schreef:
>>Erwin Moller wrote:

sheldonlg schreef:
Jerry Stuckle wrote:
>sheldonlg wrote:
>>I have a case where the session values appear to lose their
>>value. I tracked it down with some print_r inserted. Here are
>>the lines:
>>>
>>print '<br 1: '; print_r($_SESSION);
>>$adminLevel = $_POST['edit_level_list'];
>>print '<br 2: '; print_r($_SESSION);
>>>
>>Here is the output:
>>>
>>1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
>>2: Array ( [adminLevel] =[clientID] =0 )
>>>
>>There is nothing special about the variable$adminlevel. It is
>>just an ordinary local variable. Field edit_level_list is a
>>select list.
>>>
>>If I change the name of the variable from $adminLevel to $foo,
>>then the session variable does not lose its value.
>>>
>>If I then immediately set $adminLevel = $foo, the session
>>variable loses its value.
>>>
>>What is so special about the name of a local variable?
>>>
>>
>You probably have register_globals set to on - which is should NOT
>be. Turn it off.
>>
>
I don't -- unless the hosting company has that by default somehow.
I never do anything with register_globals.

DOn't guess, check. :-)

Make a file with only:
<?php
phpinfo();
?>

And see what it says.

Did that last night. See my previous reply.

Hi,

I don't see any previous reply where you said you did it.
Did you start posting via googlegroups maybe, halfway the thread?
(If so, I have dropped that response, see my sig. Sorry)

Regards,
Erwin Moller
Hi,
You didn't because it got stuck in my emailer outbox for some reason.
Aha, that explains. ;-)

I
must have had a connection failure and didn't notice it as I left the
computer to go to sleep. Here it is:

====
I just did a phpinfo. It showed that register_globals is, indeed, on.
By default it is set to off as of PHP4.2 and the version I am running is
5.2.6. The hosting company must have turned it on. Unfortunately,
according to the manual:

"Please note that register_globals cannot be set at runtime
(ini_set()). Although, you can use .htaccess if your host allows it as
described above. An example .htaccess entry: php_flag register_globals
off ."

I will have to check to see if I can have a .htaccess file.
====
Should work if they allow overwriting php-ini settings via .htaccess,
but they claim they do, so you should be fine.

Good luck.

Regards,
Erwin Moller
--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================
Aug 22 '08 #9

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

Similar topics

7
by: vivek | last post by:
Do any of you guys have any idea what might be the reason for losing session variables, i was working on a page where i had to stroe a array in a session(trust me that was the only 'way' i could...
1
by: Scott Lyon | last post by:
I'm maintaining (read: I didn't write it, nor do I have the time to spend to rewrite it) an application that is suddenly giving me grief. The reason I say suddenly, is because we're in the...
2
by: GFuller | last post by:
- We have 2 aspx pages in a .NET project. The first sets a session variable and has a button that when clicked performs a 'redirect' to the second page which then reads the session variable. ...
2
by: Joe Molloy | last post by:
Hi, This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious. I have developed a shopping cart for an application I'm working on...
4
by: Keith-Earl | last post by:
I have been writing ASP.NET apps since the RTM build and have never seen this. I built a simple app that uses session variables on my DEV laptop. All runs well. I have a simple toggle routine...
3
by: ACaunter | last post by:
Hi all, I'm wondering why I keep losing my session variables all the time. I've set the timeout to be an hour, but for some reason randomly i keep losing everything.. what could be causing this??...
0
by: Jimmy Reds | last post by:
Hi, Sorry if this appears twice but I post through Google Groups and it had a funny 5 minutes and didn't appear to post this message the first time. I am setting session variables on a page...
2
by: Jimmy Reds | last post by:
Hi, I am setting session variables on a page then doing a header/location redirect to a second page however I am losing one of my session variables. Not all of them, just one. Here are some...
0
by: jason.friesen | last post by:
Hi Folks I have a custom CMS built in classic ASP that is losing session variables. To wit, I can create a situation where my 'show all the set SVs' test page shows a different set of SVs on each...
5
by: chromis | last post by:
Hi there, I've recently been updating a site to use locking on application level variables, and I am trying to use a commonly used method which copies the application struct into the request...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.