473,811 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I set Session Variables

I need to set the information being passed through the fields (23 of
them) in the form into a session.

Where do I start?

Thanks,
Chris

Aug 22 '06 #1
6 1860

ch************* ***@gmail.com wrote:
I need to set the information being passed through the fields (23 of
them) in the form into a session.

Where do I start?

Thanks,
Chris
you want the submitted data from a form into a session?

//get the var out of the form
$var1 = $_POST["var1"];

//stick it into session
$_SESSION["var2"] = $var1;

Flamer.

Aug 22 '06 #2
I was using this which I believe accomplishes the same thing:

session_start() ;
$_SESSION['firstname'] = $_POST['firstname'];

now, if I understand correctly, the element from the _POST array should
have set the variable in the _SESSION array.

So how the heck do I retrieve it on subsiquent pages? And what sort of
settings do you need in PHP.INI for sessions to work?

I've got a ton of inherited code/programs that are using global
variables=on and I've got to turn that off as soon as I can and I'm
starting at a dead stop at the moment.

Any help is appreciated.

Chris

flamer di******@hotmai l.com wrote:
ch************* ***@gmail.com wrote:
I need to set the information being passed through the fields (23 of
them) in the form into a session.

Where do I start?

Thanks,
Chris

you want the submitted data from a form into a session?

//get the var out of the form
$var1 = $_POST["var1"];

//stick it into session
$_SESSION["var2"] = $var1;

Flamer.
Aug 22 '06 #3
ch************* ***@gmail.com wrote:
>
flamer di******@hotmai l.com wrote:
>>ch*********** *****@gmail.com wrote:

>>>I need to set the information being passed through the fields (23 of
them) in the form into a session.

Where do I start?

Thanks,
Chris

you want the submitted data from a form into a session?

//get the var out of the form
$var1 = $_POST["var1"];

//stick it into session
$_SESSION["var2"] = $var1;

Flamer.


I was using this which I believe accomplishes the same thing:

session_start() ;
$_SESSION['firstname'] = $_POST['firstname'];

now, if I understand correctly, the element from the _POST array should
have set the variable in the _SESSION array.

So how the heck do I retrieve it on subsiquent pages? And what sort of
settings do you need in PHP.INI for sessions to work?

I've got a ton of inherited code/programs that are using global
variables=on and I've got to turn that off as soon as I can and I'm
starting at a dead stop at the moment.

Any help is appreciated.

Chris
(Top posting fixed)

It's just as easy to get them out of the session:

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

The default settings in the php.ini file often work fine. Just look at
the session entries. It's pretty well documented.

The biggest problem I've seen is the session.save_pa th must point to a
directory where the web server (if you're not using the CGI version of
PHP) must have read/write access.

P.S. Please don't top post. Thanks.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Aug 22 '06 #4

Jerry Stuckle wrote:
ch************* ***@gmail.com wrote:

flamer di******@hotmai l.com wrote:
>ch************ ****@gmail.com wrote:
I need to set the information being passed through the fields (23 of
them) in the form into a session.

Where do I start?

Thanks,
Chris

you want the submitted data from a form into a session?

//get the var out of the form
$var1 = $_POST["var1"];

//stick it into session
$_SESSION["var2"] = $var1;

Flamer.

I was using this which I believe accomplishes the same thing:
>
session_start() ;
$_SESSION['firstname'] = $_POST['firstname'];
>
now, if I understand correctly, the element from the _POST array should
have set the variable in the _SESSION array.
>
So how the heck do I retrieve it on subsiquent pages? And what sort of
settings do you need in PHP.INI for sessions to work?
>
I've got a ton of inherited code/programs that are using global
variables=on and I've got to turn that off as soon as I can and I'm
starting at a dead stop at the moment.
>
Any help is appreciated.
>
Chris

(Top posting fixed)

It's just as easy to get them out of the session:

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

The default settings in the php.ini file often work fine. Just look at
the session entries. It's pretty well documented.

The biggest problem I've seen is the session.save_pa th must point to a
directory where the web server (if you're not using the CGI version of
PHP) must have read/write access.

P.S. Please don't top post. Thanks.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
I've looked and the session.save_pa th is read/write accessable, but the
majority of the session are blank so I'm not sure where I went wrong.
I'm using just this basic form at the moment:

<?php // text1.php
session_start() ;
$firstname = $_SESSION['firstname'];
$lastname = $_SESSION['lastname'];
$title = $_SESSION['title'];
$institution = $_SESSION['institution'];
$street = $_SESSION['street'];
$city = $_SESSION['city'];

// form
echo <<<HTML
<head><title>te xt1</title></head><body>
<form method="post" action="text2.p hp">
First Name: <input type="text" name="firstname " value=""/><br/>
Last Name: <input type="text" name="lastname" value=""/><br/>
Title: <input type="text" name="title" value=""/><br/>
Institution: <input type="text" name="instituti on" value=""/><br/>
Street: <input type="text" name="street" value=""/><br/>
City: <input type="text" name="city" value=""/><br/>
<input type="submit"/>
</form></body></html>
HTML;
?>

and want to be able to pull the information on any of the subsiquent 3
or 4 pages that people go through before completing it, but the session
record is blank in the file.

Aug 22 '06 #5

ch************* ***@gmail.com wrote:
Jerry Stuckle wrote:
ch************* ***@gmail.com wrote:
>
flamer di******@hotmai l.com wrote:
>
>>ch*********** *****@gmail.com wrote:
>>
>>
>>>I need to set the information being passed through the fields (23 of
>>>them) in the form into a session.
>>>
>>>Where do I start?
>>>
>>>Thanks,
>>>Chris
>>
>>you want the submitted data from a form into a session?
>>
>>//get the var out of the form
>>$var1 = $_POST["var1"];
>>
>>//stick it into session
>>$_SESSION["var2"] = $var1;
>>
>>Flamer.
>
>
I was using this which I believe accomplishes the same thing:
>
session_start() ;
$_SESSION['firstname'] = $_POST['firstname'];
>
now, if I understand correctly, the element from the _POST array should
have set the variable in the _SESSION array.
>
So how the heck do I retrieve it on subsiquent pages? And what sort of
settings do you need in PHP.INI for sessions to work?
>
I've got a ton of inherited code/programs that are using global
variables=on and I've got to turn that off as soon as I can and I'm
starting at a dead stop at the moment.
>
Any help is appreciated.
>
Chris
(Top posting fixed)

It's just as easy to get them out of the session:

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

The default settings in the php.ini file often work fine. Just look at
the session entries. It's pretty well documented.

The biggest problem I've seen is the session.save_pa th must point to a
directory where the web server (if you're not using the CGI version of
PHP) must have read/write access.

P.S. Please don't top post. Thanks.

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

I've looked and the session.save_pa th is read/write accessable, but the
majority of the session are blank so I'm not sure where I went wrong.
I'm using just this basic form at the moment:

<?php // text1.php
session_start() ;
$firstname = $_SESSION['firstname'];
$lastname = $_SESSION['lastname'];
$title = $_SESSION['title'];
$institution = $_SESSION['institution'];
$street = $_SESSION['street'];
$city = $_SESSION['city'];

// form
echo <<<HTML
<head><title>te xt1</title></head><body>
<form method="post" action="text2.p hp">
First Name: <input type="text" name="firstname " value=""/><br/>
Last Name: <input type="text" name="lastname" value=""/><br/>
Title: <input type="text" name="title" value=""/><br/>
Institution: <input type="text" name="instituti on" value=""/><br/>
Street: <input type="text" name="street" value=""/><br/>
City: <input type="text" name="city" value=""/><br/>
<input type="submit"/>
</form></body></html>
HTML;
?>

and want to be able to pull the information on any of the subsiquent 3
or 4 pages that people go through before completing it, but the session
record is blank in the file.

OK, so I've got the records writing to the session folder and I can
call them on the second page, now what I'm finding is that they won't
persist - I've inserted an intermediary page in the sequence and what
happens is that the information stored in the session file disappears.
Here is the code:

PAGE 1

<?php // text1.php
session_start() ;
$_SESSION['SID'] = session_id();

// form
echo <<<HTML
<head><title>te xt1</title></head><body>
<form method="post" action="text2.p hp">
First Name: <input type="text" name="firstname " value=""/><br/>
Last Name: <input type="text" name="lastname" value=""/><br/>
Title: <input type="text" name="title" value=""/><br/>
Institution: <input type="text" name="instituti on" value=""/><br/>
Street: <input type="text" name="street" value=""/><br/>
City: <input type="text" name="city" value=""/><br/>
<input type="submit"/>
</form></body></html>
HTML;
?>
PAGE 2

<?php // text2.php
session_start() ;
$sessionID = $_SESSION['SID'];
// Do any checking on this here maybe?
$_SESSION['firstname'] = $_POST['firstname'];
$_SESSION['lastname'] = $_POST['lastname'];
$_SESSION['title'] = $_POST['title'];
$_SESSION['institution'] = $_POST['institution'];
$_SESSION['street'] = $_POST['street'];
$_SESSION['city'] = $_POST['city'];

echo $_SESSION['firstname']; // should now work...
?>
<html>
<a href="text3.php ">Continue to next page</a>
</html>
PAGE 3

<?php // text2.php
session_start() ;
$sessionID = $_SESSION['SID'];
// Do any checking on this here maybe?

$_SESSION['firstname'] = $_POST['firstname'];
$_SESSION['lastname'] = $_POST['lastname'];
$_SESSION['title'] = $_POST['title'];
$_SESSION['institution'] = $_POST['institution'];
$_SESSION['street'] = $_POST['street'];
$_SESSION['city'] = $_POST['city'];

echo $_SESSION['firstname']; // should now work...

echo <<<HTML
<head><title>te xt2</title></head><body>
<form method="post" action="text3.p hp">
text2: <input type="text" name="text2" value="" ><br/>
<input type="submit"/><br/>
</form><p>Return to <a href="text1.php ">text1</a>.</p>
</body></html>
HTML;

echo $_POST['firstname'];

?>

The session file goes from being populated with data to this:
SID|s:32:"6ba62 4e9304bf5511a19 1a836a324c1b";f irstname|N;last name|N;title|N; institution|N;s treet|N;city|N;

I'm thinking that I didn't make the data persistant, or didn't set
something up on the link to the 3rd page correctly.

I appreciate all the help I've gotten and if anyone has an explination
about what I'm doing wrong it would be welcome.

Thanks.

Aug 22 '06 #6
ch************* ***@gmail.com wrote:
ch************* ***@gmail.com wrote:
>>Jerry Stuckle wrote:
>>>ch********** ******@gmail.co m wrote:

flamer di******@hotmai l.com wrote:
>ch******** ********@gmail. com wrote:
>
>
>
>>I need to set the information being passed through the fields (23 of
>>them) in the form into a session.
>>
>>Where do I start?
>>
>>Thanks,
>>Chris
>
>you want the submitted data from a form into a session?
>
>//get the var out of the form
>$var1 = $_POST["var1"];
>
>//stick it into session
>$_SESSIO N["var2"] = $var1;
>
>Flamer.
I was using this which I believe accomplishes the same thing:

session_start( );
$_SESSION['firstname'] = $_POST['firstname'];

now, if I understand correctly, the element from the _POST array should
have set the variable in the _SESSION array.

So how the heck do I retrieve it on subsiquent pages? And what sort of
settings do you need in PHP.INI for sessions to work?

I've got a ton of inherited code/programs that are using global
variables=on and I've got to turn that off as soon as I can and I'm
starting at a dead stop at the moment.

Any help is appreciated.

Chris

(Top posting fixed)

It's just as easy to get them out of the session:

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

The default settings in the php.ini file often work fine. Just look at
the session entries. It's pretty well documented.

The biggest problem I've seen is the session.save_pa th must point to a
directory where the web server (if you're not using the CGI version of
PHP) must have read/write access.

P.S. Please don't top post. Thanks.

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

I've looked and the session.save_pa th is read/write accessable, but the
majority of the session are blank so I'm not sure where I went wrong.
I'm using just this basic form at the moment:

<?php // text1.php
session_start ();
$firstname = $_SESSION['firstname'];
$lastname = $_SESSION['lastname'];
$title = $_SESSION['title'];
$institutio n = $_SESSION['institution'];
$street = $_SESSION['street'];
$city = $_SESSION['city'];

// form
echo <<<HTML
<head><title> text1</title></head><body>
<form method="post" action="text2.p hp">
First Name: <input type="text" name="firstname " value=""/><br/>
Last Name: <input type="text" name="lastname" value=""/><br/>
Title: <input type="text" name="title" value=""/><br/>
Institution : <input type="text" name="instituti on" value=""/><br/>
Street: <input type="text" name="street" value=""/><br/>
City: <input type="text" name="city" value=""/><br/>
<input type="submit"/>
</form></body></html>
HTML;
?>

and want to be able to pull the information on any of the subsiquent 3
or 4 pages that people go through before completing it, but the session
record is blank in the file.

OK, so I've got the records writing to the session folder and I can
call them on the second page, now what I'm finding is that they won't
persist - I've inserted an intermediary page in the sequence and what
happens is that the information stored in the session file disappears.
Here is the code:

PAGE 1

<?php // text1.php
session_start() ;
$_SESSION['SID'] = session_id();

// form
echo <<<HTML
<head><title>te xt1</title></head><body>
<form method="post" action="text2.p hp">
First Name: <input type="text" name="firstname " value=""/><br/>
Last Name: <input type="text" name="lastname" value=""/><br/>
Title: <input type="text" name="title" value=""/><br/>
Institution: <input type="text" name="instituti on" value=""/><br/>
Street: <input type="text" name="street" value=""/><br/>
City: <input type="text" name="city" value=""/><br/>
<input type="submit"/>
</form></body></html>
HTML;
?>
PAGE 2

<?php // text2.php
session_start() ;
$sessionID = $_SESSION['SID'];
// Do any checking on this here maybe?
$_SESSION['firstname'] = $_POST['firstname'];
$_SESSION['lastname'] = $_POST['lastname'];
$_SESSION['title'] = $_POST['title'];
$_SESSION['institution'] = $_POST['institution'];
$_SESSION['street'] = $_POST['street'];
$_SESSION['city'] = $_POST['city'];

echo $_SESSION['firstname']; // should now work...
?>
<html>
<a href="text3.php ">Continue to next page</a>
</html>
PAGE 3

<?php // text2.php
session_start() ;
$sessionID = $_SESSION['SID'];
No, not necessary.
// Do any checking on this here maybe?

$_SESSION['firstname'] = $_POST['firstname'];
$_SESSION['lastname'] = $_POST['lastname'];
$_SESSION['title'] = $_POST['title'];
$_SESSION['institution'] = $_POST['institution'];
$_SESSION['street'] = $_POST['street'];
$_SESSION['city'] = $_POST['city'];
You just wiped out your $_SESSION values here. You didn't post these
values to this page, did you?
echo $_SESSION['firstname']; // should now work...

echo <<<HTML
<head><title>te xt2</title></head><body>
<form method="post" action="text3.p hp">
text2: <input type="text" name="text2" value="" ><br/>
<input type="submit"/><br/>
</form><p>Return to <a href="text1.php ">text1</a>.</p>
</body></html>
HTML;

echo $_POST['firstname'];

?>

The session file goes from being populated with data to this:
SID|s:32:"6ba62 4e9304bf5511a19 1a836a324c1b";f irstname|N;last name|N;title|N; institution|N;s treet|N;city|N;

I'm thinking that I didn't make the data persistant, or didn't set
something up on the link to the 3rd page correctly.

I appreciate all the help I've gotten and if anyone has an explination
about what I'm doing wrong it would be welcome.

Thanks.
Hope this helps.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Aug 22 '06 #7

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

Similar topics

6
2394
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an email from (possibly) three seperate forms. the following code is the end of a routine which stashes data from the first form off to session variables and then redirects itself to the proper form / procedure depending upon the state of two...
6
656
by: Lina Manjarres | last post by:
Hello, I have a session variable in a login page. Then I go to a form page where I uses the ProfileID and the UserID. Then I go to a result page where I would like to use the UserID as a filter, but I can't get the value is stored in it. How can I do that? Thanks a lot!
4
5598
by: PJ | last post by:
A particular page seems to be having issues with correctly setting Session variables. I am setting a couple of session variables on the Page_Unload event. While stepping through code, the immediate window will show the values in Session after the relevant lines that set the variables in the Page_Unload event. However, on postback, these variables are no longer in Session. All Session variables that were set previous to that particular...
31
7014
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 using Session variables for three years now and i'm entering a project with my new boss who has never quite come around that session variables are ok. What's the concensus here. How can i convince him that they are ok in ASP.NET. OR
10
3522
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much more time I have on a session? If I do a refresh, does reset the session clock? Do you have have to go to another page to reset the session timeout or will a postback also do it? This is important as we have a few pages that a user
3
2915
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
3
2683
by: Phillip N Rounds | last post by:
I'm writing a user control which has two states: Active & InActive. I additionally am required that there to be only one active control per page, and all logic has to be contained within the control. In its inactive state, only a single button appears. If the user clicks on this button, the control becomes active( the rest of the control's functionality becomes visible), and all other instances of this user control on the page should...
18
3450
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that File-New-Window creates an instance of IE in the same process with the same SessionID as the parent window is in big trouble. This fundamentally restricts the usefullness of using session state management. I probably missed it somewhere - can...
26
3622
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 opens a new IE window with Ctrl-N or File-New-Window, BOTH WINDOWS SHARE THE SAME SESSION VARIABLES. This cannot be prevented.
12
3850
by: MrHelpMe | last post by:
Hello again all, I've finished my whole application and now I don't like the whole session variables that I am using. I have a form, user fills in info clicks submit and using CDOSYSMail an email link gets created with an encoded query string. i.e http://www.yahoo.ca?#$@%@&#%#$@&^@%# which translates into http://www.yahoo.ca?userID=54&LocationID=Denver. Now when the user get's this email and clicks on the link I have a
0
9728
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
10648
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10389
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
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6890
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
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
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.