954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to use session object.

I want to craete session object in my application .please tell me how to create and use session object.

msamir
Newbie Poster
7 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

You need to create a Session Object as every time someone visits your site a session is created by default. You can think of the session as a big hashtable with keys to retrieve the contents, one important thing to remember though is that Sessions dont last forever, so if someone left a page open for a long time the session would expire and the stored items would be removed

One simple example of using the Session Object would be:

string test = "test";
Session["mySessionObject"] = test;


So there it is, we already added an item to the Session. So now we probably want to look at that again later, a good tip here is that sometimes the Session object expires so always check the session object exists before casting it to its original type:

if(Session["mySessionObject"] != null)
{
string myVariable = (string) Session["mySessionObject"]; 
}
sedgey
Junior Poster
131 posts since Jan 2007
Reputation Points: 68
Solved Threads: 9
 

I am newbie,Can anyone post program using state mangement techniques

pcr
Newbie Poster
6 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 
I am newbie,Can anyone post program using state mangement techniques

basically there are four ways to handle state management :

1) viewstate
2) sessionstate
3) cookies
4) database

viewstate provides state management during postbacks

session state provides global variables that you can reach from all the pages in your application domain.

cookies are text files that are kept in the client's harddrive so you can read those during each page request

serkan sendur
Postaholic
Banned
2,062 posts since Jan 2008
Reputation Points: 854
Solved Threads: 127
 

more details in sessioncookies and cookies

aruldasrajesh
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

session is important give me also some use of it

sunilverma09
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Simple way to use Session and Display;
string str = "sample";
Session["DATA"] = str;
Response.Write(Session["DATA"].toString());

krishnamurtrhy
Newbie Poster
6 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You