User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 426,126 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,693 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2720 | Replies: 3
Reply
Join Date: Feb 2007
Posts: 7
Reputation: msamir is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
msamir msamir is offline Offline
Newbie Poster

how to use session object.

  #1  
Feb 12th, 2007
I want to craete session object in my application .please tell me how to create and use session object.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Location: Japan
Posts: 70
Reputation: sedgey is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
sedgey sedgey is offline Offline
Junior Poster in Training

Re: how to use session object.

  #2  
Feb 12th, 2007
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"]; 
}
Last edited by sedgey : Feb 12th, 2007 at 8:23 am.
sedgey: so little daylight, too much caffeine
MCSD MCAD MCSE
http://www.thefriendlybuilder.co.uk,
http://www.sheetmusicdirect.com
Reply With Quote  
Join Date: Nov 2007
Posts: 6
Reputation: pcr is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
pcr pcr is offline Offline
Newbie Poster

Re: how to use session object.

  #3  
Jan 21st, 2008
I am newbie,Can anyone post program using state mangement techniques
Reply With Quote  
Join Date: Jan 2008
Location: Largo Florida
Posts: 269
Reputation: serkansendur is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 23
serkansendur's Avatar
serkansendur serkansendur is offline Offline
Posting Whiz in Training

Re: how to use session object.

  #4  
Jan 25th, 2008
Originally Posted by pcr View Post
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 4:26 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC