473,663 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ways to assign a value to a session variable.

I am wandering which way to assign a value to a session variable
exist. Which of the following examples will work.

Example #1:
session_start() ;
session_registe r("ex");
$ex = 2.0;

Example #2:
In first.php:
session_start() ;
session_registe r("ex");
In second.php:
$ex = 2.0;

Example #3:
In first.php:
session_start() ;
session_registe r("ex");
Load second.php?ex=2 .0

Example #4:
In first.php:
session_start() ;
session_registe r("ex");
Go to the second.php via submission of the form on the first.php,
which contains form-variable $ex.

Example #4 seams not to work? Is it expectable?
Jan 14 '08 #1
12 6621
Sorry, I made a mistake. In all 4 cases the second.php should contain
session_start() ;

Jan 14 '08 #2
unless u r using an older version, otherwise avoid session_registe r
Jan 14 '08 #3

"Kurda Yon" <ku******@yahoo .comwrote in message
news:42******** *************** ***********@f47 g2000hsd.google groups.com...
Sorry, I made a mistake. In all 4 cases the second.php should contain
session_start() ;
Jan 14 '08 #4
that's a given
Jan 14 '08 #5
4 works if you did things right. cannot go more detailed than that unless
see some code.

Jan 14 '08 #6
On Jan 13, 8:43 pm, "Peter Pei" <yan...@telus.c omwrote:
unless u r using an older version, otherwise avoid session_registe r
The example #4 seems not to work. In the second file the session
variable do not want to take the value of the form variable. I tried
to force session to do it by the explicit command: $_SESSION["ex"] =
$ex; But it also does not help. I think that session value of the
variable has a higher priority with respect to the from variable. In
the first file I set the value to the session variable $ex, and than I
submit a form which change the value of the $ex variable, but the
second file does not want to see the values of the form variables. It
sees the values of the session variables.
Jan 14 '08 #7
On Mon, 14 Jan 2008 02:24:16 +0100, Kurda Yon <ku******@yahoo .comwrote:
I am wandering which way to assign a value to a session variable
exist. Which of the following examples will work.
Don't use session_registe r() anymore. Use a reference if you must.
--
Rik Wasmus
Jan 14 '08 #8
Kurda Yon wrote:
I am wandering which way to assign a value to a session variable
exist. Which of the following examples will work.

Example #1:
session_start() ;
session_registe r("ex");
$ex = 2.0;

Example #2:
In first.php:
session_start() ;
session_registe r("ex");
In second.php:
$ex = 2.0;

Example #3:
In first.php:
session_start() ;
session_registe r("ex");
Load second.php?ex=2 .0

Example #4:
In first.php:
session_start() ;
session_registe r("ex");
Go to the second.php via submission of the form on the first.php,
which contains form-variable $ex.

Example #4 seams not to work? Is it expectable?
session_registe r() has been deprecated. The correct way to do it is to
use the $_SESSION superglobal array, i.e.

session_start() ;
$_SESSION['ex'] = 2.0;

session_start() ;
$ex = $_SESSION['ex'];

BTW - there is no direct relationship between 'ex' as an index value,
and $ex as a variable.

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

Jan 14 '08 #9
there is a relationship if register_global is on, this is at least true for
5.2.5 on vista

Jan 14 '08 #10

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

Similar topics

3
1917
by: Stijn Goris | last post by:
hi all, Having a session variable test . Is there a difference between: $test = "string"; or $_session = "string"; kind regards
2
1426
by: spiderman | last post by:
How can one 'assign' value of a session variable to a variable, something like: temp = session("variable") Thanks
3
4108
by: Jesper Pedersen | last post by:
This works fine: <% Session=1; %> but this: <% Session=%> <%# DataBinder.Eval(Container.DataItem, "playerID") %> <%; %> do not work. The playerID contains the value 1, so the values in both examples are the same.
1
1412
by: Matt | last post by:
All - Is there a preferred method to assign session variables in ASP.NET / VB.NET? It looks like you can do any of the following to assign values: Session.Item("Foo") = "Bar" Session("Foo") = "Bar" Sesssion.Add("Foo", "Bar")
3
2903
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have any experience on how to keep track of session value. Any help it's appreciated. Thanks Alan
2
3401
by: Mirovk | last post by:
Hi, I have a session variable wich value arrives from a previous .asp but in my actual page I need to modify it based upon a selected value from a radio button. I will try to figure out for better understanding: page1.asp ---session("PaymentMethod") page2.asp ---Depending on the radio button selected the payment
4
20019
by: philin007 | last post by:
Hi , I have the following javascript codes: ****************************************** <script language="JavaScript"> <!-- .... ..... if (nextRow >5) {
38
2305
by: Zytan | last post by:
What is the difference between these two lines? Dim args As Object() = New Object() {strText} Dim args As Object() = {strText} args seems usuable from either, say, like so: Me.Invoke(delegate, args) Zytan
2
7205
by: rahullko05 | last post by:
i am stuck in the problem, where after user logs in successfuly, i take him to the login thanks page. now on that page i need to retain the login name. I am not sure how to this. i have written a query string which passes the SID from this page. <a href="loginthanks.php?<?php echo htmlspecialchars(SID); ?>" > now how can i send the login name to next page. Also i want to store this value of login name in some session variable, so...
0
8436
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
8771
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...
1
8548
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8634
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7371
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...
0
5657
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();...
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
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.