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

session var is setting ONLY AFTER I reload page, form var displays first page load

Page1 has a form that calls Page2. The beginning of Page2:
<? php session_start();
$s=$_POST['sSelected'];
session_register("s"); ?>

in the middle of Page2 I have a form varaible:
<?php echo $_POST['stateSelected']; ?>
<?php echo $_SESSION['s']; ?>

The form var displays the first time the page loads. The session var
displays only after reloading the page2.

Why?
Jul 17 '05 #1
3 2335
On Fri, 23 Jul 2004 16:16:14 -0400, "NotGiven" <no****@nonegiven.net>
wrote:
Page1 has a form that calls Page2. The beginning of Page2:
<? php session_start();
$s=$_POST['sSelected'];
session_register("s"); ?>

in the middle of Page2 I have a form varaible:
<?php echo $_POST['stateSelected']; ?>
<?php echo $_SESSION['s']; ?>

The form var displays the first time the page loads. The session var
displays only after reloading the page2.

Why?


because that's how HTTP works... read and learn.

w3c is a good starting place, although i seem to remember that the
php.net documentation regarding cookies and/or sessions might give you
a good insight into this.

simple solution to your problem: call session_start() in Page1
Jul 17 '05 #2
NotGiven <no****@nonegiven.net> wrote:
Page1 has a form that calls Page2. The beginning of Page2:
<? php session_start();
$s=$_POST['sSelected'];
session_register("s"); ?>

in the middle of Page2 I have a form varaible:
<?php echo $_POST['stateSelected']; ?>
<?php echo $_SESSION['s']; ?>

The form var displays the first time the page loads. The session var
displays only after reloading the page2.


Don't use session_register with _SESSION (see the manual), fix your code
($_SESSION['s']=...) and your problem will vanish.

--

Daniel Tryba

Jul 17 '05 #3
Thank!
"Daniel Tryba" <ne****************@canopus.nl> wrote in message
news:cd**********@news.tue.nl...
NotGiven <no****@nonegiven.net> wrote:
Page1 has a form that calls Page2. The beginning of Page2:
<? php session_start();
$s=$_POST['sSelected'];
session_register("s"); ?>

in the middle of Page2 I have a form varaible:
<?php echo $_POST['stateSelected']; ?>
<?php echo $_SESSION['s']; ?>

The form var displays the first time the page loads. The session var
displays only after reloading the page2.


Don't use session_register with _SESSION (see the manual), fix your code
($_SESSION['s']=...) and your problem will vanish.

--

Daniel Tryba

Jul 17 '05 #4

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

Similar topics

11
by: HolaGoogle | last post by:
hi all, can you please tell me what i should do to avoid session timeout when displaying my database info in my asp form (DisplayUserDatabase.asp)??? ** actualy it does load and display the...
1
by: Marshall Dudley | last post by:
I need to be able to allow a user to submit a form which opens another window. This part I have working. But after the submit, I need to delay and have the original window do a reload. I cannot...
3
by: M Wells | last post by:
Hi All, Just wondering how you go about changing the value of a session cookie via javascript? I have a PHP page that sets a session cookie when it first loads. I'd like to be able to change...
0
by: Satish Appasani | last post by:
Hi: I have a ASP.NET form with Web layout which I've achieved using panels. In one of the tab I have a File control to upload Images. When I put a file in the file control and move to another...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
4
by: N. Demos | last post by:
Hello, I'm learning ASP.NET, and am having a strange problem with some example code from the book I'm using. The code increments and displays the value stored in a session variable when the "Add"...
3
by: Ned Balzer | last post by:
Hi all, I posted this question some time ago in an earlier thread but so far I still don't have an understanding of why this is happening or what I can do to fix it. I use Session variables,...
5
by: Finn Stampe Mikkelsen | last post by:
Hi How can i set a focus to a textbox in my codebehind page?? I have this WebForm, that takes information from a user and 2 buttons on the form. One that takes action on the entered...
3
by: rn5a | last post by:
A ASPX Form has a TextBox & a Button. Users enter their username in the TextBox & submit the Form after which records pertaining to the username get retrieved from a MS-Access database table &...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
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
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,...
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...

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.