views:

28

answers:

3

Hi

I'm storing the orders in sessions and i give the possibilty to user to delete the order, but i'm trying to create an "undo" but i don't know how.

When the user ask to delete the session (the order), what you advice me to do to have the possibility to undo it? It don't need to be after X minutes, just in the same page so if he deletes the order, he see an option to undo the action.

Thanks

+4  A: 

Store the deleted orders in a special "place" in the session, e.g:

Session["deleted_orders"] = new List<Order>();
...

Or add a Deleted flag to the order object.

M4N
Thanks mate, i haven't thought about that ;)
Guilherme Cardoso
+1  A: 

Just add another key to the session [OrderDeleted] = true;

Developer Art
A: 

If your session state manager is kept in SQL this will be as simple as creating a copy of the session data into an "expired" table. If you keep session in memory, then on delete, create a copy of the session data in a SQL table somewhere along with a timestamp. This allows the record to be destroyed after it has grown moldy enough, but will live long enough that if the undo is clicked, the data you need can be restored.

Joel Etherton