This is a discussion on "Save data in Arrays during sessions" within the PHP Forum section. This forum, and the thread "Save data in Arrays during sessions are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Save data in Arrays during sessions
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Save data in Arrays during sessions
Hi I'm a new member and I need some help here
I've got a book selling site and I'm trying to create a way of customers clicking on buttons generated from a query and that list of book IDs or titles appearing in a text area box in a form ready for posting as email. The question is about sessions and arrays Now I need to preserve data across multiple clicks, as the book IDs are added to an array - registered in a session. My problem - and I think a lot of people have had this - is that the array data is not preserved between pages. The code i've got so far is :
OK i've used session_register which many say is no good but there is no security issue here - no logins or credit card numbers - just passing info to an email form. And it works - BUT when I go back and click on another book button the array doesn't get any bigger - there is always just ONE element in it - because the info in the array isn't being preserved 'between' pages. I understand this is a bug in versions of php after 4.0 or something and I've seen some people recommend $_SESSION - which I've sort of tried but that doesn't even seem to enter one element. Can anyone help me out here ? Andy Last edited by c010depunkk; Oct 23rd, 2007 at 18:21. Reason: added [PHP] tags |
|
|
|
||||
|
Re: Save data in Arrays during sessions
$_SESSION works on anything later then 4.1.0. And earlier versions have $HTTP_SESSION_VARS. I've never heard of this problem before and I've coded with everything since PHP 3.*....
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
Last edited by c010depunkk; Oct 23rd, 2007 at 18:26. Reason: i sounded unfriendly.. :D |
|
||||
|
Re: Save data in Arrays during sessions
I have had similar problems.
If you have php >= 4.1 you could use
When you want to get the array in $_SESSION['stuff'] you can use $someStuff = unserialize($_SESSION['stuff']); Hope that helps, Cheers,
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Problems with arrays | Scream | JavaScript Forum | 2 | Jan 10th, 2008 16:15 |
| arrays images and backgroundImage | gleb | JavaScript Forum | 0 | Sep 9th, 2007 20:39 |
| Looping through arrays | assgar | Starting Out | 1 | Apr 22nd, 2007 18:43 |
| sending email arrays with php | ppgpilot | PHP Forum | 2 | Jan 25th, 2007 16:49 |
| arrays? | macupryk | ASP.NET Forum | 1 | Sep 30th, 2003 12:44 |