Sublime directory Surf the web anonymous Pagerank Monitor


Storing session variable

FixMySite
Tue 21 November 2006, 08:02 pm GMT +0100
Question:

Currently in some of my sites, i'm using a session variable for various things.  A client wants the ability to save a session state and then reload it later.  Clearly I can do this by saving it in a database, but i was wondering, what kind of variable is a session state variable? is it text? can i just pull it out of the db and load it back in as a session variable and have it pull the exact state back up?

thanks guys.

Jason

edit: i'm using asp.net and vb.net and a mysql server

Nikolas
Tue 21 November 2006, 08:05 pm GMT +0100
I think the correct answer is what you say (text)

I have no experience from vb in sites (I use to code vb for applications), but anyway in the database you will propably need a text field

FixMySite
Tue 21 November 2006, 08:07 pm GMT +0100
so if someone wanted to save the state of a form, i just save the session variable in a text field in a database and then call it up later and load it into the session variable when they want to reload their form?  is it really that easy?

Nikolas
Tue 21 November 2006, 08:13 pm GMT +0100
so if someone wanted to save the state of a form, i just save the session variable in a text field in a database and then call it up later and load it into the session variable when they want to reload their form?  is it really that easy?

Yeah. But when you have to store more values(eg. an array), then you should serialize the data. I don't know how to do that in vb so you will have to search for that.

The only thing that you should worry when you are inserting in the database is to be sure that there are no ' in your data, but I guess you allready know that, right?

FixMySite
Tue 21 November 2006, 08:18 pm GMT +0100
haha...clearly.  thanks!

olaf
Tue 21 November 2006, 09:31 pm GMT +0100
Or set a cookie to store the data is less safe but also less work (maybe is this the session state)

btw. Jason, its time to switch to real web applications powered by PHP :D

FixMySite
Tue 21 November 2006, 09:34 pm GMT +0100
haha...yeah, when i'm ready to use a poorly-architected procedure-based language, i'll be sure to have you come teach me PHP.  for now i'll stick with OOP and .NET.  thanks :)

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional