views:

31

answers:

1

Hello, I'm trying to find the best way to persist an object or in use the same object at a later point in the code. So, I create an object, then you're redirected to another page(a form) that needs to use variables from that object. That form is submitted to a third party and there is stuff done on their end and then they request a page on my application that runs some more code and needs the objects variables again.

  • I thought about Database but this is all done at once. This is done during a user checkout process and after it's over, there's no reason to retrieve this object again. So adding and retrieving from a database seems like it would be overkill and I think it would make the process slower.
  • Right now I'm using Session but I keep hearing not to use that but no one is really saying why I shouldn't except it is bad practice.
  • I can't really use post back values because the pages don't work that way. The checkout process starts off in a dll code that redirects to the form that is submitted to the third party and the a page is requested by the third party.
  • Started reading about Cache object but I haven't used this yet and I am not sure about it yet.

So, I'm not really sure of the best way. What are all the options and what does everyone recommend as the best way?

+1  A: 

If you use Session, and the session expires, you lose the data. The user would have to start over. Also, all that data is hanging around until 20 minutes after the user leaves the page, by default

Persisting it in a database isn't bad, and the record can give you useful audit trail data later.

The cache object is a global cache, so its not specific to any particular user. Any user or page in the application domain can access that data. You could use the username to keep it, but I think the database is a better option

Lerxst
Another problem with the DB, is that for every user that checks out, they'll have a record in the database. It could be thousands of records and I don't even need to access those values ever again once they checkout. I'd have to delete the record after they're done. Doesn't that seem like a waist?
Doesn't session only expire if the user stops requesting pages and like 20 minutes after. This is all taking place during a checkout process so I don't think I'd lose session at this point.
depends on what you want. why would it be a waste to store a record and then delete it if you don't need it? you could even transfer some of the data to an auditing table and discard the rest.If you put a lot of data into session variables, you have all that hanging around on your web server until 20 minutes after the user leaves the page.
Lerxst