Saturday, March 24, 2012

Session Variables

I have no idea how to use session variables... anyone know a good web site that explanes and teaches how to use them?? could not find anything on 4guysfromrolla... and some other sites, if you know somewhere, please let me know.

Thank you.It's really very easy. In fact the Session object is just a collection that is unique on a per-user basis (so each user has his own session and thus his own session object). To store something in the Session-collection use this syntax:

VB
Session("nameofthevalue") = someobject

C#
Session["nameofthevalue"] = someobject;

To retrieve a value from the Session collection, use the inverted syntax (e.g. with a String object):

VB
myString = CType(Session("nameofthevalue"),String)

C#
myString = (string) Session["nameofthevalue"];

Hope this helps?
Maybe you can explain in brief what you want to achieve. This would allow us to give a practical example...
Try this site:

http://samples.gotdotnet.com/quickstart/aspplus/

And select "Managing Application State" from the Table of Content on the Left Frame.

It is an ASP.NET QuickStart Tutorial with code samples in both VB.NET and C#.NET.

Hope this helps..

0 comments:

Post a Comment