Forums
This topic is locked
PHP Sessions
Posted 07 Mar 2003 23:36:04
1
has voted
07 Mar 2003 23:36:04 Chris Trygstad posted:
can you store multiple values in a single session variable in php? to be more exact, I'm trying to develop a primitive shopping cart-like thingy. I have a list of parts under a table in a db. Click on the part#, you go to the detail page. In the detail page, I'll have a form built in under the details, allowing you to enter quantities, and whether you want new or used in checkboxes. I want the submit button (form action) to add the item to another table, using the partkey, quantity, and new/used options. The add record action I have just added, I want to redirect to the shopping cart for that customer (or items under that session variable, right?) Maybe its just becuase it Friday, but I can't figure out what to do. Do I set the variables by highlight the form, under binding, select session variables? I don't know what I'm doing wrong, or what I need to do to get this to go. I want to get the customer info at check out, but I want to keep track of what they want througout the application. Do I need to handcode a php file that will handle the session variables? Replies
Replied 12 Mar 2003 14:16:36
12 Mar 2003 14:16:36 Tim Green replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Do I need to handcode a php file that will handle the session variables?<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Yes you do. Dreamweaver doesn't provide access to Session Variables in the way that you need them, but a session variable can be used to store any information.
For example you can store a complex array in a variable and assign this to your session, using something like:-
session_start();
$myVar['Item_Number'] = "001";
$myVar['Name'] = "Test";
$myVar['Price'] = "99.99";
$myVar['quantity'] = 1;
$HTTP_SESSION_VARS['mySess'] = $myVar
(or indeed replace HTTP_SESSION_VARS for _SESSION if you are using PHP v4.1.0 or upwards)
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Yes you do. Dreamweaver doesn't provide access to Session Variables in the way that you need them, but a session variable can be used to store any information.
For example you can store a complex array in a variable and assign this to your session, using something like:-
session_start();
$myVar['Item_Number'] = "001";
$myVar['Name'] = "Test";
$myVar['Price'] = "99.99";
$myVar['quantity'] = 1;
$HTTP_SESSION_VARS['mySess'] = $myVar
(or indeed replace HTTP_SESSION_VARS for _SESSION if you are using PHP v4.1.0 or upwards)
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>