|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
storing user choices across pages
I have many pages with choices that users can select through checkboxes. I was wondering how can I allow users choices to be remembered. Once they choose 10, it will store it all in a database. I have thought about these options:
through the url: this won't work well because these are pages that won't always need the user to make choices, and if the user were to leave these pages to another page, it wouldn't remember previous choices. cookies: I thought that maybe this would work, but I'm not sure how to store multiple values in one cookie, at different times. I have thought of this: user checks boxes, which are sent as an array, and then I store in cookie as comma seperated values. One each page requiring it, the page gets the cookie and then adds new array values to it... and then rewrite old cookie. I'm not sure how to do this though... I could write to a text file, but is this practical? It seems the best way to me... I could just store in database as user checks them off, but this would mean making MULTIPLE UPDATE statements, rathar than getting all values and then making one query. Any ideas on what would work best? Or another method? Thanks.
__________________
hey it's the CHARKING |
|
#2
|
|||
|
|||
|
PHP Code:
The only consideration with sessions is maintaining their state. You can set session.gc_maxlifetime (i believe that's the variable, this is off the top of my head) to something like 9999999999 by using the ini_set() function (www.php.net/ini_set) Also, check out the PHP documentations for sessions for more examples. http://www.php.net/session_start Hope this helped! EDIT: forgot to call session_name() in the above code Last edited by dbalatero : October 1st, 2003 at 09:07 PM. |
|
#3
|
|||
|
|||
|
OH, and, as for cookies, there's no reason you couldn't set a cookie with the comma-separated values as you wrote above, then when you want to add to it, you can take the string and write to the end of it with a new entry.
If you wanted to edit that CSV string and remove an item, you'd just do the following: PHP Code:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > storing user choices across pages |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|