[PHP] Sessions and Arrays
Hello, In an attempt to override the political anger in this mailing list I will tell you that I have already searched through documentations on how to solve the problem I'm having, to the extent of my skills in searching. Ok, now to the problem. I have an array submitted by a form, such as $item['name'], $item['desc'], $item['price'], etc, and I want to register only individual items of the array in a session, while still preserving the array structure -- i.e. while not breaking the array into separate variables. It says nothing in the docs, and I am not in front of a box running PHP at this particular time to test it, but would it make sense to do something like: session_register(item['name'], item['price']); and not have to include the $item['desc'] in the sessions? Sometimes, in my application, I do not want to include the $item['desc']. I want to keep the session alive throughout the script and add more individual array items to it as well, such as say $item['height'], $item['width'], etc, while still having the choice to exclude some of the array items from being registered in the $item session. I'm not sure if I made any sense here, but if someone can attempt to answer this, I would appreciate it greatly. Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions and Arrays
Did you try it? Did it work? How about $_SESSION['item']['price'] = $item['price']; $_SESSION['item']['name'] = $item['name']; ---John Holmes... - Original Message - From: @ Darwin [EMAIL PROTECTED] To: Php-General [EMAIL PROTECTED] Sent: Tuesday, November 05, 2002 3:11 PM Subject: [PHP] Sessions and Arrays Hello, In an attempt to override the political anger in this mailing list I will tell you that I have already searched through documentations on how to solve the problem I'm having, to the extent of my skills in searching. Ok, now to the problem. I have an array submitted by a form, such as $item['name'], $item['desc'], $item['price'], etc, and I want to register only individual items of the array in a session, while still preserving the array structure -- i.e. while not breaking the array into separate variables. It says nothing in the docs, and I am not in front of a box running PHP at this particular time to test it, but would it make sense to do something like: session_register(item['name'], item['price']); and not have to include the $item['desc'] in the sessions? Sometimes, in my application, I do not want to include the $item['desc']. I want to keep the session alive throughout the script and add more individual array items to it as well, such as say $item['height'], $item['width'], etc, while still having the choice to exclude some of the array items from being registered in the $item session. I'm not sure if I made any sense here, but if someone can attempt to answer this, I would appreciate it greatly. Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sessions and Arrays
I cannot try it out until after a few hours -- work restrictions -- please forgive me. I'm trying to break down your suggestion here. So calling those two lines will actually register the sessions? In other words, does $_SESSION['item']['price'] register the session the same way as session_register(item['price']); would? P.S. -- On the development machine at home I have register_globals on, and I realize the security risks involved. The production machine will also have register_globals on. -Original Message- From: 1LT John W. Holmes [mailto:holmes072000;charter.net] Sent: Tuesday, November 05, 2002 4:03 PM To: @ Darwin; Php-General Subject: Re: [PHP] Sessions and Arrays Did you try it? Did it work? How about $_SESSION['item']['price'] = $item['price']; $_SESSION['item']['name'] = $item['name']; ---John Holmes... - Original Message - From: @ Darwin [EMAIL PROTECTED] To: Php-General [EMAIL PROTECTED] Sent: Tuesday, November 05, 2002 3:11 PM Subject: [PHP] Sessions and Arrays Hello, In an attempt to override the political anger in this mailing list I will tell you that I have already searched through documentations on how to solve the problem I'm having, to the extent of my skills in searching. Ok, now to the problem. I have an array submitted by a form, such as $item['name'], $item['desc'], $item['price'], etc, and I want to register only individual items of the array in a session, while still preserving the array structure -- i.e. while not breaking the array into separate variables. It says nothing in the docs, and I am not in front of a box running PHP at this particular time to test it, but would it make sense to do something like: session_register(item['name'], item['price']); and not have to include the $item['desc'] in the sessions? Sometimes, in my application, I do not want to include the $item['desc']. I want to keep the session alive throughout the script and add more individual array items to it as well, such as say $item['height'], $item['width'], etc, while still having the choice to exclude some of the array items from being registered in the $item session. I'm not sure if I made any sense here, but if someone can attempt to answer this, I would appreciate it greatly. Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sessions and Arrays
Hello Everyone, How do I send a single array, with many values, through sessions? For example, I might have the following: ?php session_start(); session_register(product); $product['category'] = appetizer; $product['name'] = Miso Soup; $product['desc'] = Some Description; $product['price'] = 4.95; ? By registering just the product array, will I have all of the values of that array available to me throughout the entire session? Or will I have to register each array variable-value pair separately, like so: session_register(product['category'], product['name'], product['description'], product['price'], ); Any help and suggestions on sending arrays through sessions will be greatful, thanks! :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions and Arrays
On Monday 20 May 2002 04:31, Navid Y. wrote: Hello Everyone, How do I send a single array, with many values, through sessions? For example, I might have the following: [snip] Why? don't you just try it? Surely it's quicker to write some simple test code than to ask on the list? By registering just the product array, will I have all of the values of that array available to me throughout the entire session? Yes Or will I have to register each array variable-value pair separately, like so: No -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Maybe we can get together and show off to each other sometimes. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sessions and Arrays
Jason, I did try it before asking, else I wouldn't have any reason to ask. It didn't work for me, but I thought that maybe I was missing something. So your answer is yes, it is possible? I guess I'll have to keep testing my application. Thanks for your time, I really appreciate it. Navid -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Sunday, May 19, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Sessions and Arrays On Monday 20 May 2002 04:31, Navid Y. wrote: Hello Everyone, How do I send a single array, with many values, through sessions? For example, I might have the following: [snip] Why? don't you just try it? Surely it's quicker to write some simple test code than to ask on the list? By registering just the product array, will I have all of the values of that array available to me throughout the entire session? Yes Or will I have to register each array variable-value pair separately, like so: No -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Maybe we can get together and show off to each other sometimes. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php