473,800 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($_SESSI ON);
$adminLevel = $_POST['edit_level_lis t'];
print '<br 2: '; print_r($_SESSI ON);

Here is the output:

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

There is nothing special about the variable$adminl evel. 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 1775
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($_SESSI ON);
$adminLevel = $_POST['edit_level_lis t'];
print '<br 2: '; print_r($_SESSI ON);

Here is the output:

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

There is nothing special about the variable$adminl evel. 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_global s 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*******@attgl obal.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($_SESSI ON);
$adminLevel = $_POST['edit_level_lis t'];
print '<br 2: '; print_r($_SESSI ON);

Here is the output:

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

There is nothing special about the variable$adminl evel. 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_lis t'] = 'foo';
print '<br 1: '; print_r($_SESSI ON);
$adminLevel = $_POST['edit_level_lis t'];
print '<br 2: '; print_r($_SESSI ON);
?>
-----%<----- 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($_SESSI ON);
$adminLevel = $_POST['edit_level_lis t'];
print '<br 2: '; print_r($_SESSI ON);

Here is the output:

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

There is nothing special about the variable$adminl evel. 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_global s 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_global s.
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($_SESSI ON);
$adminLevel = $_POST['edit_level_lis t'];
print '<br 2: '; print_r($_SESSI ON);

Here is the output:

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

There is nothing special about the variable$adminl evel. 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_global s 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_global s.
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($_SESSI ON);
$adminLeve l = $_POST['edit_level_lis t'];
print '<br 2: '; print_r($_SESSI ON);

Here is the output:

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

There is nothing special about the variable$adminl evel. 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_global s 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_global s.

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($_SESSI ON);
$adminLev el = $_POST['edit_level_lis t'];
print '<br 2: '; print_r($_SESSI ON);
>
Here is the output:
>
1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
2: Array ( [adminLevel] =[clientID] =0 )
>
There is nothing special about the variable$adminl evel. 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_global s 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_global s.

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($_SESSI ON);
>$adminLeve l = $_POST['edit_level_lis t'];
>print '<br 2: '; print_r($_SESSI ON);
>>
>Here is the output:
>>
>1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
>2: Array ( [adminLevel] =[clientID] =0 )
>>
>There is nothing special about the variable$adminl evel. 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_global s 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_global s.

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_global s 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_global s 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_global s
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:
>sheldonl g 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($_SESSI ON);
>>$adminLev el = $_POST['edit_level_lis t'];
>>print '<br 2: '; print_r($_SESSI ON);
>>>
>>Here is the output:
>>>
>>1: Array ( [adminLevel] =SUPERUSER [clientID] =0 )
>>2: Array ( [adminLevel] =[clientID] =0 )
>>>
>>There is nothing special about the variable$adminl evel. 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
>>variabl e loses its value.
>>>
>>What is so special about the name of a local variable?
>>>
>>
>You probably have register_global s 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_global s.

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_global s 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_global s 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_global s
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
7795
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 imagine doing it), and i am losing the session variable, its just returning empty values...does any one has any ideas?
1
2789
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 process of transitioning the server on which it runs from Microsoft Windows 2000 Server, to 2003 server (going from IIS 5 to IIS 6). This problem hasn't really occurred on the 2000 server machine, but it's happening MUCH more on the new 2003 box (not...
2
2360
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. Problem: This always works fine on the localserver and through the IDE. But when the application is put onto a www website, the following occurs; - If you browse to the site using the IP address, session variables work fine
2
6167
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 which is loosely based on the e-commerce example in the quickstarts tutorial. In the cart display I have provided functionality so that when a user clicks on a product name a popup is opened with the full product details displayed.
4
2408
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 that checks the status of a Session variable. I keep losing the value of the variable. When I trace the page it is there, but it is gone next postback. Also, I use three tier objects and store my DataManager object in a session variable. It is...
3
1992
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?? also, is there a way to automatically go back to the login page as soon as the sessions have expired or are lost. thanks
0
1397
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 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.
2
1561
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 details/comments: I am doing a session_start() on ALL of my pages, right at the top of each page
0
1821
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 refresh of the browser. My test page goes a little something like this: <h1>Checking Session Variables</h1> <h2>Checking what session variables are set.</h2> <p>
5
6136
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 scope. Application variables are then accessed in this manner Request.App.<Var>. To begin with I had a simple functioning login system inside a subdirectory named admin, this subdirectory had it's own application.cfm, I wasn't sure whether to duplicate...
0
9691
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
9551
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
10276
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...
0
9090
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7580
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
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.