0

I have an app that allows the user to add items to a list. They can also sort and remove items from that list, but that's not really the point of this question.

The question is, would it be best to use the SESSION for this or a COOKIE?

I've tried looking around the web for some similar example tutorials but I've come up short.

dcolumbus
  • 9,596
  • 26
  • 100
  • 165
  • Personally I would use local storage with a polyfill for older browsers, but that's just me ? – adeneo Jan 25 '13 at 19:16
  • 3
    The question is what you are doing it with it after the user is finished. You can also write them to a database, a file or whatever you like. It really depends on what you like to achieve and if the user should be able to see the storage. – flec Jan 25 '13 at 19:17
  • No point to writing it to the database. The idea is that they compose a list and then have that list emailed to them. – dcolumbus Jan 25 '13 at 19:18
  • The sorting could also be handled in the query string depending on what you're going for. – Matt Whipple Jan 25 '13 at 19:27

4 Answers4

0

Normally sorting is done using sessions. Common practisch is sorting using jQuery and save it to a session using AJAX for when the user refreshes the page or uses pagination. Flow:

  1. Select tabledata from database using default order
  2. Store order in session using PHP
  3. Let jQuery use AJAX to get ORDER from session
  4. If its the same as default -> no ordering
  5. If the session is different then default -> order table
  6. User clicks order -> order table using jQuery
  7. Save new order using jQuery and use AJAX to save it to session like in step 2
Chris Visser
  • 1,607
  • 12
  • 24
0

Is that list gonna be saved on a database? If so, everytime the user put or remove a new item from that list, you could do an operation on the database depending on what was changed. Using this approach the only thing you should keep track of, are sort operations. Which you can handle using http get/post parameters or cookies.

Ygor Henrique
  • 53
  • 1
  • 8
0

I think you have to do what is best for your application, but here's a post about session vs. cookie Cookie VS Session

Community
  • 1
  • 1
Eduardo Pino
  • 66
  • 1
  • 5
0

Not sure why the answer was deleted, but this was by far the best solution: http://www.jstorage.info/

I love HTML 5.

dcolumbus
  • 9,596
  • 26
  • 100
  • 165