472,960 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,960 software developers and data experts.

variables that change session variables

Hi, I'm currently writing a mulit-page form app that uses a session to
retain data from each form element in order for the user to jump
between pages, then the final data is passed to a calculation script.

However, I've noticed that if I assign a session variable to another
variable, which then performs a mathematical calculation, the session
variable changes.

i.e. $_SESSION["inflation"] = 4;
$temp_inf = $_SESSION["inflation"];
if ($_SESSION["inflation"] =="RPI") {
$inflation = $rpi;}
else {$inflation = ($temp_inf/100.0);}
now it equals = 0.04

How can I take a value from a session and perform operations on it
without altering the original session value.
Rgds
Neil.
Jul 16 '05 #1
1 6579
sentinel wrote:
However, I've noticed that if I assign a session variable to another
variable, which then performs a mathematical calculation, the session
variable changes.

i.e. $_SESSION["inflation"] = 4;
$temp_inf = $_SESSION["inflation"];
if ($_SESSION["inflation"] =="RPI") {
$inflation = $rpi;}
else {$inflation = ($temp_inf/100.0);}
now it equals = 0.04

How can I take a value from a session and perform operations on it
without altering the original session value.


This happends because you have the register_globals directive turned on
and thus, $_SESSION['inflation'] and $inflation contain the same value
and if you manipulate one the other changes as well.

There's two solutions to your problem, either change your naming (i.e.
switch from $_SESSION['inflation'] to $_SESSION['foo'] or from
$inflation to $bar) or turn register_globals off.
Per Gustafsson

--
http://www.pergustafsson.com/
Jul 16 '05 #2

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

Similar topics

3
by: Microsoft | last post by:
I am using Session variables in my ASP application. I have tested the application on a Win2k professional and it works fine. When the same web app is installed on a win2k advanced server from the...
14
by: qaz | last post by:
I've always used session cookies in my web sites. However, since more and more people (including me) are starting to disable cookies, I'm beginning to think that I should change my ways and design...
14
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you...
31
by: Harry Simpson | last post by:
I've come from the old ASP camp where session variables were not used. When i started using ASP.NET in 2001, I started using them again because it was ok from what I'd read. I've been merrily...
3
by: bennett | last post by:
In the web.config file for my application, in the <sessionState> section I have set timeout="120" (in minutes), but session state variables in my application seem to be expiring in about 5 minutes....
7
by: Erik | last post by:
I have an application that uses sessions variables a lot but one I publish the application on the prod server these variables are lost. The application is written i c# 2.0 and I've set the...
26
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
5
by: dougloj | last post by:
Howdy. I have an ASP.NET application written in C#. I know this sounds nuts, but instead of having multiple .aspx files to display various parts of the Web site, I do almost everything on my...
2
by: DLN | last post by:
Hello all, I apologize for the naivety of this question, but I'm wondering whether session variables can ever be modified (somehow) by a client without having to go through code that I write. ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.