473,799 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_SESSION vs. $variable

Ken
What am I doing wrong?

I set the variable co_name on the first page with an <input.... > and
session_start() at the top of both pages.

Clicking on a link that takes me to the second page:

Script on the second page.

echo $_SESSION['co_name']; Does not display
value of co_name
echo "Variable name co_name = ".$co_name; Displays value of co_name

One book suggested using echo {$_SESSION['co_name']}; Does not run.

Server is Apache2 Triad

Any suggestions. I would like to use $_SESSION incase I move to another
server without ??register_glob als?? ON

Thanks for the help.
Jul 17 '05 #1
5 2977
Ken wrote:
What am I doing wrong?

I set the variable co_name on the first page with an <input.... > and
session_start() at the top of both pages.

Clicking on a link that takes me to the second page:

Script on the second page.

echo $_SESSION['co_name']; Does not display
value of co_name
echo "Variable name co_name = ".$co_name; Displays value of co_name

One book suggested using echo {$_SESSION['co_name']}; Does not run.

Server is Apache2 Triad

Any suggestions. I would like to use $_SESSION incase I move to another
server without ??register_glob als?? ON

Thanks for the help.


You have considered the manual at php.net ?
Especially about session_registe r("co_name") prior to $_SESSION["co_name"] =
"something" on the first page ?

Or rather, in your case a minor rewrite according to the input statement ?

/Andreas
--
Peace and long life ...
Registeret Linux user #292411
Jul 17 '05 #2
Ken wrote:
What am I doing wrong?

I set the variable co_name on the first page with an <input.... > and
session_start() at the top of both pages.
How are you putting co_name into the session variable on the first page?
Clicking on a link that takes me to the second page:

Script on the second page.

echo $_SESSION['co_name'];


The PHP manual for session_registe r()
( @ http://www.php.net/session_register )
has a word of caution against using session_registe r() and $_SESSION
together.
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
Ken wrote:
What am I doing wrong?

I set the variable co_name on the first page with an <input.... > and
session_start() at the top of both pages.

Clicking on a link that takes me to the second page:

Script on the second page.

echo $_SESSION['co_name']; Does not display
value of co_name
echo "Variable name co_name = ".$co_name; Displays value of co_name

One book suggested using echo {$_SESSION['co_name']}; Does not run.

Server is Apache2 Triad

Any suggestions. I would like to use $_SESSION incase I move to another
server without ??register_glob als?? ON

Thanks for the help.


Now thinking of it a bit further - please do disregard my other post.
What you want is not sessions, but a way to read form input on another page.

If the form is of method=POST, on the page that is called then you can read
each variable by $_POST["fieldname"], if it's a method=GET of course using
$_GET["fieldname"] or alternatively, $_REQUEST["fieldname"].

Sessions, is a totally different subject.
And you were referring to register_global s, so this is what you wanted and
this doesn't need a session_start() at each page in order to work.

/Andreas
--
Peace and long life ...
Registeret Linux user #292411
Jul 17 '05 #4
Ken
I want to carry variables from the input page through to 2 or 3 other pages;
then save the variables in a table or array for future downloading.

There can be several user transferring data at the same time.

What is the best way to do that?

I thought sessions would keep the data from being intermingled between
users.

What is the operational difference between

$_SESSION['variable]

$variable

$_POST['variable']

Thanks for the help.

Ken

"Ken" <kk******@wi.rr .com> wrote in message
news:IF******** ***********@twi ster.rdc-kc.rr.com...
What am I doing wrong?

I set the variable co_name on the first page with an <input.... > and
session_start() at the top of both pages.

Clicking on a link that takes me to the second page:

Script on the second page.

echo $_SESSION['co_name']; Does not display
value of co_name
echo "Variable name co_name = ".$co_name; Displays value of co_name

One book suggested using echo {$_SESSION['co_name']}; Does not run.

Server is Apache2 Triad

Any suggestions. I would like to use $_SESSION incase I move to another
server without ??register_glob als?? ON

Thanks for the help.

Jul 17 '05 #5
Ken wrote:
What is the operational difference between

$_SESSION['variable]

$variable

$_POST['variable']


| creation | lifetime | scope
------------+------------------+----------------+---------
$variable | first use | end of script | local
$_POST[] | init (by client) | end of script | global
$_SESSION[] | init (by server) | end of session | global

I think this pretty much sums it up :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #6

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

Similar topics

0
2602
by: Thomas Carcaud | last post by:
I read php manual many times but I can't figure out register_globals works. I m using Php 4.3.2 and register_globals on. It seems to have different effects on $_GET and $_SESSION. First with $_GET : <? echo $var."\n"; echo $_GET."\n"; $var="gna"; echo $var."\n"; echo $_GET."\n"; $_GET="gnou";
3
14907
by: Phil Powell | last post by:
PHP: unset($_SESSION); In my original environment (PHP 4.3.2) this line will delete the session variable 'mainDisplay'. But in the testing environment (PHP 4.3.6) the variable persists even after unset() is called. Is there some special setting in PHP that can allow a session to
4
1941
by: comp.lang.php | last post by:
This is an urgent request (as always) generate_admin_customer_position_dropdown($customerResult, $customerResult->id); print_r($_SESSION); This code will generate an HTML dropdown as well as set a $_SESSION
12
41196
by: Michael Windsor | last post by:
I've been trying to integrate some PHP pages of my own with some existing code. The details of this are for the support forums for that code (where I have been asking questions), but I wonder if someone here can enlighten me as to why the problematic code is having the effect it is. For reasons I don't know, if the PHP version is 5 or greater, register_long_arrays is false and $_SESSION exists, the following statement is executed: ...
15
5959
by: Evil Otto | last post by:
My page loads, and calls an init() function that returns content to a div on the page, as well as setting a $_SESSION variable. The content it returns includes a link that calls the same variable, but I get an error that says the index isn't defined. The second two calls are AJAX-generated. The second call immediately echos the $_SESSION variable back after it sets it, and it sets it properly. But the subsequent request doesn't see...
1
2893
by: bsprogs | last post by:
I am currnetly programming a file hosting website in PHP and I am slowly integrating AJAX into the website. Here is my problem: The user uploads the file. The server processes the file and stores a $_SESSION variable. After the upload is complete, the server supplies a link that allows the user to view their link codes. Once they click the link, the page will return the information stored in the $_SESSION variable. The normal link which...
4
2349
by: dpinion | last post by:
Greetings, I am trying to do some simple session stuff. However it does not seem as though the session variable is being created for my site. I am running the latest version of PHP and apache that I installed as part of WAMP. Machine is XP SP2. Basically I am trying to do something simple such as: <?php
2
2268
by: sharonDonnelly | last post by:
Hi Really dumb problem that's got me beat. Can someone help. The prolem: I'm trying to count the number of times an item has been clicked. There are many items. I want to create a session variable for each item as its clicked, and increment the value held by the session variable by 1 each time that item is clicked. My plan was to allow an item to be selected on one page - when a user selects an item, a numeric value will be passed to a...
4
1813
TheServant
by: TheServant | last post by:
Hi guys, This is my situation. I have 3 sets of data used on every page of my website. Two of these never change, and the reason they are stored in MySQL and recalled into the $_SESSION variable is simply because I want to have one place to update/change them if I ever need to. What I have been wondering is if I should leave the user specific variables in the session, and define the other variables in another file/array which is called on...
0
9540
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10250
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
10222
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
10026
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
9068
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
6805
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();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
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
3
2938
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.