I'm designing a web application that has to pass sensitive information (like the user's account number) from page to page until the user is done (the application is like a wizard), for logging purposes. What is the best way of storing this data so that each page in the process can get access to the data? Should I be storing it in the session? In the database, then delete it at the end? Some method I haven't thought of yet?
-
Possibly associate each customer with a GUID, use that to pass from page to page - checking if its been tampered with etc... Then maybe a service call to a wcf service to bring back the more sensitive info as and when you need, again locked down accordingly/ – Chris May 10 '12 at 08:57
-
Thanks for the comment Chris, but what I'm interested in is where and how to store that GUID. – Daniel T. May 10 '12 at 08:59
-
If you pass as a parameter from controller -> view etc in your posts back and forth, you should be ok, right? I'm quite new to MVC3 but if you check it hasnt been tampered with then you should be fine security wise? – Chris May 10 '12 at 09:25
2 Answers
I personally try to avoid using the session where possible. Here are the options that I know of when dealing with wizard type scenarios:
Option 1
Use JQuery as discussed in Nadeem Afana's blog. The pages are displayed to the user one by one but the information is not submitted until the final page.
Option 2
Is the information on every page sensitive? Could it be structured so that the sensitive information is just asked for on the final page? If so you could serialize data across the pages as discussed in Darin Dimitrovs answer and just not provide a back button on the final page. Alternatively, the data that is serialized can be encrytped with ease using the same MVC Futures serialization software although i'm not sure how sensitive your information is and whether you would want to rely on this. The answer also mentions alternatives such as Stepy but I have no experience with this.
Option 3
If the information is sensitive you could write/read the information to a database between requests.
Option 4
Finally, if you can't use any of the above then I would use the Session or TempData (which is a wrapper around the session) but beware that with TempData, if the user refreshes the page then the information will be lost.
-
Thanks for the answer. I believe only 3 or 4 would work for me. I need the sensitive information to do logging at every step so that we know if the user encountered an error and if they've completed the entire workflow. – Daniel T. May 10 '12 at 09:51
Session sounds fine to me, it goes away (almost) automatically.
If you are paranoid then you can encrypt it or store it somewhere else and find it through a hash. This "somewhere else" is then your next point of save-enough-?
Just make sure it doesn't reach the web client.

- 7,195
- 6
- 56
- 107