Saturday, 06 September 2008
DotNetSpace, Asp.net 2.0 tutorials and code examples. ajax, log4net...
Home arrow Articles arrow General Articles arrow Using the Session object
 
Main Menu
Home
Articles
News
Links
Search








BiraJones




Using the Session object Print E-mail
Sunday, 05 November 2006


This code example shows how to store objects in the Session object ins ASP.NET.

You don't really need to remove objects from Session object because it only lasts during the session lifetime. However, you can remove objects by using the Session.Remove() method or the RemoveAll() method. You might want to use these two methods to conserve Web server resources, especially if you store large objects in Session. (Code in C#)

/// Saving a string to Session key 'customer'.
string customerName = 'JoeSmith';
Session.Add("customer", customerName);

/// Retrieving the session object.
string customerName = (string)Session["customer"];

Last Updated ( Friday, 08 December 2006 )
 
< Prev   Next >
Popular
Polls
-->*/?>

Which language will you choose for coding with Visual Studio .NET?
 
-->*/?>

Is ASP.NET better than Java / JSP frameworks?
 

© 2008 DotNetSpace
Joomla! is Free Software released under the GNU/GPL License.