hi everyone,
i am trying to set a session variable (array) but unable to figure out how to do that. I am able to set a single variable but i need to set an array.
for instance i am alble to do following:
session_start();
$cart = array();
$_SESSION['cart'] = '1234';
but i want to set the value(index) of the cart array also. for instance:
session_start()
$cart = array();
Now supossingly, i set an index for the cart array.
$cart['isbn'] = '1234';
Now i am not able to set cart index as a session variable.
i tried this, but was unable to get how to set the array along with the index.
$_SESSION[$cart['isbn']] = '1234';
i wrote this but got error. I do not want to use session_register, instead i want to use $_SESSION super globals as it is more secure.
Thanx.
Gaurav
Problem setting array as a session variable - urgent help.
Moderator: General Moderators
-
gaurav_sting
- Forum Newbie
- Posts: 19
- Joined: Sat Mar 27, 2004 3:45 am
- Location: Delhi
- andre_c
- Forum Contributor
- Posts: 412
- Joined: Sun Feb 29, 2004 6:49 pm
- Location: Salt Lake City, Utah
Try this:
... since $_SESSION is an array, now you made it a multi-dimesional array. (array of arrays)
Code: Select all
$_SESSION['cart']['isbn'] = '1234';
$_SESSION['cart']['other'] = 'blah';