473,396 Members | 1,996 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,396 software developers and data experts.

Losing some session values

Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).

I have done some tests.

$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;

Passes ok and has value 67 on the next page
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;

Passes ok and has value abc on the next page
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;

No value on next page
Other session variables seem ok also.

Confused of Bromley

Thanks John

Nov 1 '08 #1
18 1716
John wrote:
Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).

I have done some tests.

$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;

Passes ok and has value 67 on the next page
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;

Passes ok and has value abc on the next page
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;

No value on next page
Other session variables seem ok also.

Confused of Bromley

Thanks John
And you have gone back with the values you know that work just to make
sure you did not goof up the code after testing the one that does not work?

Maybe it's a typo here but S_SESSION should be $_SESSION.

Shoot us the actual code, sometimes there are small procedural problems
that don't transcribe when writing it to the NG.

Scotty

Nov 1 '08 #2
On Sat, 01 Nov 2008 07:16:09 -0700, FutureShock <fu**********@att.net>
wrote:
>John wrote:
>Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).

I have done some tests.

$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;

Passes ok and has value 67 on the next page
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;

Passes ok and has value abc on the next page
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;

No value on next page
Other session variables seem ok also.

Confused of Bromley

Thanks John

And you have gone back with the values you know that work just to make
sure you did not goof up the code after testing the one that does not work?

Maybe it's a typo here but S_SESSION should be $_SESSION.

Shoot us the actual code, sometimes there are small procedural problems
that don't transcribe when writing it to the NG.

Scotty
Thanks Scotty

My mistake in this post I'm afraid. All $_SESSION variables correct.

Here they are cut & pasted -

Page 1 - Set up
$_SESSION['org_details'] = $_POST['ORD_ORG'];

Page 1 use
<h1><?php echo $_SESSION['org_details']; ? OK

Page 2 use
echo $_SESSION['org_details'];
Value is empty

John
Nov 1 '08 #3
John wrote:
Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).

I have done some tests.

$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;

Passes ok and has value 67 on the next page
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;

Passes ok and has value abc on the next page
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;

No value on next page
Other session variables seem ok also.

Confused of Bromley

Thanks John
Are you using anything like Smarty templates or some other such thing?
Does debug or verbose output help show anything?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
Nov 1 '08 #4
On Sat, 01 Nov 2008 13:17:28 +0000, John <67vnue6o@knwfvwrote:
Here's the testing I did -

PAGE 1 CODE

$_SESSION[org_details] = $_POST['ORD_ORG'];
echo "1-$_SESSION[org_details]*<BR>";

$temp = 67;
$_SESSION[org_details1] = $temp;
echo "2-$temp-$_SESSION[org_details1]*<BR>";

$temp = $_POST['ORD_ORG']."1";
$_SESSION[org_details2] = $temp;
echo "3-$temp-$_SESSION[org_details2]*<BR>";

$temp = "adbr";
$_SESSION[org_details3] = $temp;
echo "4-$temp-$_SESSION[org_details3]*<BR>";

PAGE 1 RESULTS

1-Deptford Boys School*
2-67-67*
3-Deptford Boys School1-Deptford Boys School1*
4-adbr-adbr*

PAGE 2 CODE

echo
"--$_SESSION[org_details]-<BR>--$_SESSION[org_details1]-<BR>--$_SESSION[org_details2]-<BR>--$_SESSION[org_details3]";

PAGE 2 RESULTS
---
--67-
--1-
--adbr

(The strings inside the [] don't seem to make a difference)

John
Nov 1 '08 #5
John <67vnue6o@knwfvwrote:
echo
"--$_SESSION[org_details]-<BR>--$_SESSION[org_details1]-<BR>--$_SESSION[org_details2]-<BR>--$_SESSION[org_details3]";

PAGE 2 RESULTS
---
--67-
--1-
--adbr

(The strings inside the [] don't seem to make a difference)
Maybe you intended:
echo "--{$_SESSION['org_details']}--<BR... etc etc?

HTH,

--
Charles

Nov 1 '08 #6
On Sat, 01 Nov 2008 19:23:07 +0000, Charles Polisher
<cp*****@nonesuch.comwrote:
>John <67vnue6o@knwfvwrote:
>echo
"--$_SESSION[org_details]-<BR>--$_SESSION[org_details1]-<BR>--$_SESSION[org_details2]-<BR>--$_SESSION[org_details3]";

PAGE 2 RESULTS
---
--67-
--1-
--adbr

(The strings inside the [] don't seem to make a difference)

Maybe you intended:
echo "--{$_SESSION['org_details']}--<BR... etc etc?

HTH,
Thanks Charles.

I can't see why the others work without the brace though.

I stored the $_POST value in a db so I was able to pull it out again
which defeats the use of the session variable.

There seems to be some conflict between POST and SESSION but I can't
think what I have chabged that could make a difference.

--
John

Nov 1 '08 #7
John wrote:
On Sat, 01 Nov 2008 19:23:07 +0000, Charles Polisher
<cp*****@nonesuch.comwrote:
>John <67vnue6o@knwfvwrote:
>>echo
"--$_SESSION[org_details]-<BR>--$_SESSION[org_details1]-<BR>--$_SESSION[org_details2]-<BR>--$_SESSION[org_details3]";

PAGE 2 RESULTS
---
--67-
--1-
--adbr

(The strings inside the [] don't seem to make a difference)
Maybe you intended:
echo "--{$_SESSION['org_details']}--<BR... etc etc?

HTH,

Thanks Charles.

I can't see why the others work without the brace though.

I stored the $_POST value in a db so I was able to pull it out again
which defeats the use of the session variable.

There seems to be some conflict between POST and SESSION but I can't
think what I have chabged that could make a difference.
All i can think of doing now to verify your values is output all your
session values.

print_r($_SESSION);

on both pages and see what comes out for sure.

Also you may want to print_r($_POST) on page one to verify your values
there too.

Always remember 'junk in, junk out'

Scotty
Nov 2 '08 #8
Message-ID: <5u********************************@4ax.comfrom John
contained the following:
>Here's the testing I did -
That's still not the whole code, we can't see the form that produces the
$_POST variable. My guess is that you are reloading the page somehow
without posting the form which is destroying the session variable.

You will be better off using concatenation with session variables to
avoid possible problems with mathematical operators (eg - and * )

echo
'--'.$_SESSION['org_details'].'-<BR>--'.$_SESSION['org_details1'].'-<BR>--'.$_SESSION['org_details2'].'-<BR>--.'$_SESSION['org_details3'];

Reduce it down to the smallest possible snippets of code that produce
the problem. If the solution is not obvious, post the code.
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Nov 2 '08 #9
Geoff Berrow wrote:
Message-ID: <5u********************************@4ax.comfrom John
contained the following:
>Here's the testing I did -

That's still not the whole code, we can't see the form that produces the
$_POST variable. My guess is that you are reloading the page somehow
without posting the form which is destroying the session variable.

You will be better off using concatenation with session variables to
avoid possible problems with mathematical operators (eg - and * )

echo
'--'.$_SESSION['org_details'].'-<BR>--'.$_SESSION['org_details1'].'-<BR>--'.$_SESSION['org_details2'].'-<BR>--.'$_SESSION['org_details3'];

Reduce it down to the smallest possible snippets of code that produce
the problem. If the solution is not obvious, post the code.
There is no need to use concatenation - braces within double-quoted
strings work quite well. It's only a matter of style. But he also
needs single quotes around the array names;

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

Nov 2 '08 #10
John wrote:
On Sat, 01 Nov 2008 13:17:28 +0000, John <67vnue6o@knwfvwrote:
Here's the testing I did -

PAGE 1 CODE

$_SESSION[org_details] = $_POST['ORD_ORG'];
echo "1-$_SESSION[org_details]*<BR>";

$temp = 67;
$_SESSION[org_details1] = $temp;
echo "2-$temp-$_SESSION[org_details1]*<BR>";

$temp = $_POST['ORD_ORG']."1";
$_SESSION[org_details2] = $temp;
echo "3-$temp-$_SESSION[org_details2]*<BR>";

$temp = "adbr";
$_SESSION[org_details3] = $temp;
echo "4-$temp-$_SESSION[org_details3]*<BR>";

PAGE 1 RESULTS

1-Deptford Boys School*
2-67-67*
3-Deptford Boys School1-Deptford Boys School1*
4-adbr-adbr*

PAGE 2 CODE

echo
"--$_SESSION[org_details]-<BR>--$_SESSION[org_details1]-<BR>--$_SESSION[org_details2]-<BR>--$_SESSION[org_details3]";

PAGE 2 RESULTS
---
--67-
--1-
--adbr

(The strings inside the [] don't seem to make a difference)

John
You need braces around your array elements when using them in a
double-quoted string, and single quotes around the array indexes.

The correct way to do it would be:

echo
"--{$_SESSION['org_details']}-<BR>--{$_SESSION['org_details1']}-<BR>--{$_SESSION['org_details2']}-<BR>--{$_SESSION['org_details3']}";

Additionally, as NN indicated, ensure you have session_start() at the
beginning of EVERY page which uses session data.

And ensure you have these in the php.ini file on your development system:

display_errors=on
error_reporting=E_ALL

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

Nov 2 '08 #11
On Sat, 01 Nov 2008 13:17:28 +0000, John <67vnue6o@knwfvwrote:
>Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).

I have done some tests.

$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;

Passes ok and has value 67 on the next page
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;

Passes ok and has value abc on the next page
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;

No value on next page
Other session variables seem ok also.

Confused of Bromley

Thanks John
OK found it. Sorry for the wild goose chase but I do appreciate your
help.

Problem was I was using a header to redirect without an exit and the
code was re-executing which meant that some $_POST variables were not
set the second time around.

I now realise I've used headers before without an exit, can I assume
the whole of the code is always run again or this inconsistent?

--
John

Nov 2 '08 #12
John wrote:
On Sat, 01 Nov 2008 13:17:28 +0000, John <67vnue6o@knwfvwrote:
>Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).

I have done some tests.

$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;

Passes ok and has value 67 on the next page
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;

Passes ok and has value abc on the next page
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;

No value on next page
Other session variables seem ok also.

Confused of Bromley

Thanks John

OK found it. Sorry for the wild goose chase but I do appreciate your
help.

Problem was I was using a header to redirect without an exit and the
code was re-executing which meant that some $_POST variables were not
set the second time around.

I now realise I've used headers before without an exit, can I assume
the whole of the code is always run again or this inconsistent?
Maybe, maybe not. header() is just a function call. Execution
continues after the call. But in the case of a redirect, the execution
will continue only until the next request comes in from that browser -
after which the code will be terminated (by default). Depending on
system load, the amount of code left, link speed, browser response time,
the phase of the moon and whether you hold your left foot with your
right hand in the correct position or not, code may or may not complete.

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

Nov 2 '08 #13
On Sun, 02 Nov 2008 11:36:55 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>John wrote:
>On Sat, 01 Nov 2008 13:17:28 +0000, John <67vnue6o@knwfvwrote:
>>Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).

I have done some tests.

$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;

Passes ok and has value 67 on the next page
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;

Passes ok and has value abc on the next page
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;

No value on next page
Other session variables seem ok also.

Confused of Bromley

Thanks John

OK found it. Sorry for the wild goose chase but I do appreciate your
help.

Problem was I was using a header to redirect without an exit and the
code was re-executing which meant that some $_POST variables were not
set the second time around.

I now realise I've used headers before without an exit, can I assume
the whole of the code is always run again or this inconsistent?

Maybe, maybe not. header() is just a function call. Execution
continues after the call. But in the case of a redirect, the execution
will continue only until the next request comes in from that browser -
after which the code will be terminated (by default). Depending on
system load, the amount of code left, link speed, browser response time,
the phase of the moon and whether you hold your left foot with your
right hand in the correct position or not, code may or may not complete.
So I can envisage a scenario whereby a user clicks a submit button
expecting to go to another page. A redirect is used and the next page
starts processing, perhaps retrieving data from a large database and
carrying out some calculations.

What you are saying is the user will see his page presented back to
him first, in this case. Now while processing is happening on the
second page, it is not hard to image a communications link seizing up
such that the new second page is held up.

To the user it looks like nothing has happened but in fact the fist
page has been processed again, and items updated possibly.

Is that correct?

--
John
Nov 3 '08 #14
John wrote:
On Sun, 02 Nov 2008 11:36:55 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>John wrote:
>>On Sat, 01 Nov 2008 13:17:28 +0000, John <67vnue6o@knwfvwrote:

Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).

I have done some tests.

$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;

Passes ok and has value 67 on the next page
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;

Passes ok and has value abc on the next page
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;

No value on next page
Other session variables seem ok also.

Confused of Bromley

Thanks John
OK found it. Sorry for the wild goose chase but I do appreciate your
help.

Problem was I was using a header to redirect without an exit and the
code was re-executing which meant that some $_POST variables were not
set the second time around.

I now realise I've used headers before without an exit, can I assume
the whole of the code is always run again or this inconsistent?
Maybe, maybe not. header() is just a function call. Execution
continues after the call. But in the case of a redirect, the execution
will continue only until the next request comes in from that browser -
after which the code will be terminated (by default). Depending on
system load, the amount of code left, link speed, browser response time,
the phase of the moon and whether you hold your left foot with your
right hand in the correct position or not, code may or may not complete.

So I can envisage a scenario whereby a user clicks a submit button
expecting to go to another page. A redirect is used and the next page
starts processing, perhaps retrieving data from a large database and
carrying out some calculations.

What you are saying is the user will see his page presented back to
him first, in this case. Now while processing is happening on the
second page, it is not hard to image a communications link seizing up
such that the new second page is held up.

To the user it looks like nothing has happened but in fact the fist
page has been processed again, and items updated possibly.

Is that correct?
That's not at all what I said. Please read it again. There is no way
to display a second page without a request from the client.


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

Nov 3 '08 #15
On Mon, 03 Nov 2008 07:58:13 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>John wrote:
>On Sun, 02 Nov 2008 11:36:55 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>>John wrote:
On Sat, 01 Nov 2008 13:17:28 +0000, John <67vnue6o@knwfvwrote:

Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).
>
I have done some tests.
>
$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;
>
Passes ok and has value 67 on the next page
>
>
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;
>
Passes ok and has value abc on the next page
>
>
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;
>
No value on next page
>
>
Other session variables seem ok also.
>
Confused of Bromley
>
Thanks John
OK found it. Sorry for the wild goose chase but I do appreciate your
help.

Problem was I was using a header to redirect without an exit and the
code was re-executing which meant that some $_POST variables were not
set the second time around.

I now realise I've used headers before without an exit, can I assume
the whole of the code is always run again or this inconsistent?

Maybe, maybe not. header() is just a function call. Execution
continues after the call. But in the case of a redirect, the execution
will continue only until the next request comes in from that browser -
after which the code will be terminated (by default). Depending on
system load, the amount of code left, link speed, browser response time,
the phase of the moon and whether you hold your left foot with your
right hand in the correct position or not, code may or may not complete.

So I can envisage a scenario whereby a user clicks a submit button
expecting to go to another page. A redirect is used and the next page
starts processing, perhaps retrieving data from a large database and
carrying out some calculations.

What you are saying is the user will see his page presented back to
him first, in this case. Now while processing is happening on the
second page, it is not hard to image a communications link seizing up
such that the new second page is held up.

To the user it looks like nothing has happened but in fact the fist
page has been processed again, and items updated possibly.

Is that correct?

That's not at all what I said. Please read it again. There is no way
to display a second page without a request from the client.
Sorry Jerry I don't understand in the case.

In my scenario the client did request the second page:
So I can envisage a scenario whereby a user clicks a submit button
expecting to go to another page.
I may have not been clear with this. The redirect is at the top of the
page and the page calls itself. That is why it would continue
processing the second around.

--
John

Nov 3 '08 #16
John wrote:
On Mon, 03 Nov 2008 07:58:13 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>John wrote:
>>On Sun, 02 Nov 2008 11:36:55 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:

John wrote:
On Sat, 01 Nov 2008 13:17:28 +0000, John <67vnue6o@knwfvwrote:
>
>Something strange has just started to happen as I have been developing
>a db application on a site. Suddenly a session variable has stopped
>working as I pass it from 1 page to another (I am sure it was OK a few
>days ago).
>>
>I have done some tests.
>>
>$temp = 67;
>echo $temp; gives 67 on this page
>S_SESSION['org'] = $temp;
>>
>Passes ok and has value 67 on the next page
>>
>>
>$temp = "abc"
>echo $temp gives "abc" on this page
>S_SESSION['org'] = $temp;
>>
>Passes ok and has value abc on the next page
>>
>>
>$temp = $_POST['CUST_ORG']
>echo $temp; gives "org 1" on this page
>S_SESSION['org'] = $temp;
>>
>No value on next page
>>
>>
>Other session variables seem ok also.
>>
>Confused of Bromley
>>
>Thanks John
OK found it. Sorry for the wild goose chase but I do appreciate your
help.
>
Problem was I was using a header to redirect without an exit and the
code was re-executing which meant that some $_POST variables were not
set the second time around.
>
I now realise I've used headers before without an exit, can I assume
the whole of the code is always run again or this inconsistent?
>
Maybe, maybe not. header() is just a function call. Execution
continues after the call. But in the case of a redirect, the execution
will continue only until the next request comes in from that browser -
after which the code will be terminated (by default). Depending on
system load, the amount of code left, link speed, browser response time,
the phase of the moon and whether you hold your left foot with your
right hand in the correct position or not, code may or may not complete.
So I can envisage a scenario whereby a user clicks a submit button
expecting to go to another page. A redirect is used and the next page
starts processing, perhaps retrieving data from a large database and
carrying out some calculations.

What you are saying is the user will see his page presented back to
him first, in this case. Now while processing is happening on the
second page, it is not hard to image a communications link seizing up
such that the new second page is held up.

To the user it looks like nothing has happened but in fact the fist
page has been processed again, and items updated possibly.

Is that correct?
That's not at all what I said. Please read it again. There is no way
to display a second page without a request from the client.

Sorry Jerry I don't understand in the case.

In my scenario the client did request the second page:
>So I can envisage a scenario whereby a user clicks a submit button
expecting to go to another page.

I may have not been clear with this. The redirect is at the top of the
page and the page calls itself. That is why it would continue
processing the second around.
You can't send two pages to the same client. If you output ANYTHING
(even white space) from the first page, the header() call will fail.

If, instead, you use the header('Location: ...') call to redirect, the
client will request the new page. At that time, the connection for the
first page will be closed. Any time after that, processing of the first
page may be terminated by PHP. There is no guarantee whether or not the
code on the first page will complete or not. This is typically when the
first page attempts to send output to the client, but that's not
guaranteed, AFAIK.

The bottom line is - if you want to redirect AND do processing - do ALL
of your processing before the header() call. Don't count on processing
to continue after the header('Location: ...') call.

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

Nov 3 '08 #17
John wrote:
Something strange has just started to happen as I have been developing
a db application on a site. Suddenly a session variable has stopped
working as I pass it from 1 page to another (I am sure it was OK a few
days ago).

I have done some tests.

$temp = 67;
echo $temp; gives 67 on this page
S_SESSION['org'] = $temp;

Passes ok and has value 67 on the next page
$temp = "abc"
echo $temp gives "abc" on this page
S_SESSION['org'] = $temp;

Passes ok and has value abc on the next page
$temp = $_POST['CUST_ORG']
echo $temp; gives "org 1" on this page
S_SESSION['org'] = $temp;

No value on next page
Given lack of time I'm not browsing the total thread, but if:
- register_globals enabled?
- (possibly global) variable named $org?
Then:
- Try to disable register_globals and see if the problem continues.
- If unable to do that, or this doesn't fix it, try to use a different name.

If things still get weird, I normally employ a "bogus" singleton object
around my $_SESSION array, use that (and solely that) to set my
$_SESSION values, in which case I can monitor & log alteration with the
__get() & __set() methods.

My server doesn't carry alt.* groups, removed
--
Grtz,

Rik
Nov 3 '08 #18
On Mon, 03 Nov 2008 12:58:55 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>John wrote:
>On Mon, 03 Nov 2008 07:58:13 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>>John wrote:
On Sun, 02 Nov 2008 11:36:55 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:

John wrote:
>On Sat, 01 Nov 2008 13:17:28 +0000, John <67vnue6o@knwfvwrote:
>>
>>Something strange has just started to happen as I have been developing
>>a db application on a site. Suddenly a session variable has stopped
>>working as I pass it from 1 page to another (I am sure it was OK a few
>>days ago).
>>>
>>I have done some tests.
>>>
>>$temp = 67;
>>echo $temp; gives 67 on this page
>>S_SESSION['org'] = $temp;
>>>
>>Passes ok and has value 67 on the next page
>>>
>>>
>>$temp = "abc"
>>echo $temp gives "abc" on this page
>>S_SESSION['org'] = $temp;
>>>
>>Passes ok and has value abc on the next page
>>>
>>>
>>$temp = $_POST['CUST_ORG']
>>echo $temp; gives "org 1" on this page
>>S_SESSION['org'] = $temp;
>>>
>>No value on next page
>>>
>>>
>>Other session variables seem ok also.
>>>
>>Confused of Bromley
>>>
>>Thanks John
>OK found it. Sorry for the wild goose chase but I do appreciate your
>help.
>>
>Problem was I was using a header to redirect without an exit and the
>code was re-executing which meant that some $_POST variables were not
>set the second time around.
>>
>I now realise I've used headers before without an exit, can I assume
>the whole of the code is always run again or this inconsistent?
>>
Maybe, maybe not. header() is just a function call. Execution
continues after the call. But in the case of a redirect, the execution
will continue only until the next request comes in from that browser -
after which the code will be terminated (by default). Depending on
system load, the amount of code left, link speed, browser response time,
the phase of the moon and whether you hold your left foot with your
right hand in the correct position or not, code may or may not complete.
So I can envisage a scenario whereby a user clicks a submit button
expecting to go to another page. A redirect is used and the next page
starts processing, perhaps retrieving data from a large database and
carrying out some calculations.

What you are saying is the user will see his page presented back to
him first, in this case. Now while processing is happening on the
second page, it is not hard to image a communications link seizing up
such that the new second page is held up.

To the user it looks like nothing has happened but in fact the fist
page has been processed again, and items updated possibly.

Is that correct?

That's not at all what I said. Please read it again. There is no way
to display a second page without a request from the client.

Sorry Jerry I don't understand in the case.

In my scenario the client did request the second page:
>>So I can envisage a scenario whereby a user clicks a submit button
expecting to go to another page.

I may have not been clear with this. The redirect is at the top of the
page and the page calls itself. That is why it would continue
processing the second around.

You can't send two pages to the same client. If you output ANYTHING
(even white space) from the first page, the header() call will fail.

If, instead, you use the header('Location: ...') call to redirect, the
client will request the new page. At that time, the connection for the
first page will be closed. Any time after that, processing of the first
page may be terminated by PHP. There is no guarantee whether or not the
code on the first page will complete or not. This is typically when the
first page attempts to send output to the client, but that's not
guaranteed, AFAIK.

The bottom line is - if you want to redirect AND do processing - do ALL
of your processing before the header() call. Don't count on processing
to continue after the header('Location: ...') call.
Thanks Jerry

I think its clear now.

--
John

Nov 3 '08 #19

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: 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...
5
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the...
0
by: Reza Solouki | last post by:
Hi, I have a case where an item could have n subitems, so while doing the alterations to the subitems, I need to keep the arraylist in session. It was working fine in the development machine,...
9
by: Adrian Parker | last post by:
We have a website that works everywhere but on a few PCs on this one site.. Asp.Net 1.1 Server = Windows 2003 Client = XP In the web.config we use - cookieless="false" in the browser settings...
6
by: Sukh | last post by:
Hi, I am using ASP.Net with C#. My application is using a control and when control object is created my application set all the values to that control. This also contain connection string...
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
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
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...
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,...

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.