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

Question about session variables and visiting various pages.

I am working on a site that will have several pages and where the user will
find some investment advices. I must say that the concept of
sessions/session variables is relatively new for me.
What I noticed is the following: when I write "form method is ""post"
action = page2.php", and in page2.php I write
"session_register("someVariable") the value of the variable is registered
but if I visit some further pages and go back to page1, I cannot change the
value of the variable anymore by changing the content of the form field. The
only thing I can figure out to resolve this problem would using the
HTTP_REFERER : if the user comes from page 2 the variable should be
unregistered in page 1, so it can be registered in page 2 again.
I have been looking in Google for better alternatives for such a multiple
page site but maybe I just entered the wrong searching keywords.
Any suggestion or even a link to a page that discusses this topic will be
very welcome.
Thanks,
Martien van Wanrooij

Jul 17 '05 #1
2 2665
The interactive between GET, POST, and session variables is rather confusing
when register_globals is turned on. Basically, a GET or a POST cannot
overwrite a session variable. After you registered a variable its value can
only be changed programmatically.

Avoid using session_register(). Instead, access session variables through
$_SESSION[]. Say you want a variable that changes when a POST occurs, but
stays put as you go from page to page, you would do something like:

if(isset($someVariable)) {
$_SESSION['someVariable] = $someVariable;
}
else {
$someVariable = $_SESSION['someVariable'];
}

Uzytkownik "Martien van Wanrooij" <in**@martienvanwanrooij.nl> napisal w
wiadomosci news:KKzMb.822$tK2.1810@amstwist00...
I am working on a site that will have several pages and where the user will find some investment advices. I must say that the concept of
sessions/session variables is relatively new for me.
What I noticed is the following: when I write "form method is ""post"
action = page2.php", and in page2.php I write
"session_register("someVariable") the value of the variable is registered
but if I visit some further pages and go back to page1, I cannot change the value of the variable anymore by changing the content of the form field. The only thing I can figure out to resolve this problem would using the
HTTP_REFERER : if the user comes from page 2 the variable should be
unregistered in page 1, so it can be registered in page 2 again.
I have been looking in Google for better alternatives for such a multiple
page site but maybe I just entered the wrong searching keywords.
Any suggestion or even a link to a page that discusses this topic will be
very welcome.
Thanks,
Martien van Wanrooij

Jul 17 '05 #2

"Chung Leong" <ch***********@hotmail.com> schreef in bericht
news:5a********************@comcast.com...
Avoid using session_register(). Instead, access session variables through
$_SESSION[]. Say you want a variable that changes when a POST occurs, but
stays put as you go from page to page, you would do something like:

if(isset($someVariable)) {
$_SESSION['someVariable] = $someVariable;
}
else {
$someVariable = $_SESSION['someVariable'];
}

Thank you Chung, I think this will resolve my problem :)
Jul 17 '05 #3

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

Similar topics

9
by: Xizor | last post by:
Let's say I run a server. I have two people using the server. Bill and Joe. Bill is at address.com/bill and Joe is at address.com/joe. Let's say Joe and Bill are both using PHP with sessions on...
5
by: Larry Woods | last post by:
I am losing Session variables, but only those that are set in the page previous to a redirect to a secure page. Anyone seen ANY situation where Session variables just "disappear?" Note that...
3
by: Jessica Loriena | last post by:
I'm trying to write a simple "register form / validate and store in database / show welcome screen" application with ASP.Net. With conventional ASP, I used Session variables and it went something...
2
by: Boban Dragojlovic | last post by:
I'm building a complex web-based reservations system. Gathering the user's data requires between 8 and 15 pages (depending on which options they are interested in). I use the "Session" object to...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
14
by: Coleen | last post by:
Hi All :-) We have an APSX application using VB.net as the code behind, which uses one or two session variables per page. These Session variables are passed to the final page and calculations...
1
by: David Gaudine | last post by:
(This is a bit like the recent thread "PHP Switching Sessions".) I use session_start(). When I open my web-based application in two windows on the same system, there's a definite clash; I can't...
0
by: tharika_c | last post by:
Hi, We have a simple ASP.NET web application where one of the Session variables, called Session("SSO_ID") gets created and assigned a value (equal to the HTTP_HRID request variable value),...
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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
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,...

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.