C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Adding and Retrieving Session variables with HttpContext


Posted Date: 03 Apr 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms

Posted By: Raju.M       Member Level: Gold
Rating:     Points: 7



The code sample illustrates the method to add and retrieve session variables in a ASP.NET page. In the PersistFunction class below, the AddSession and RetrieveSession functions are responsbile for these respective jobs. They do it by using the HttpContext class and a session id. Session ids are responsible to track various sessions with the users.




using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public class PersistFunctions
{
public PersistFunctions()
{
}
public void AddSession(string sessionID, object sessionValue)
{
HttpContext.Current.Session[sessionID] = sessionValue;
}
public object GetSession(string sessionID)
{
return HttpContext.Current.Session[sessionID];
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Using HttpContext to add and retrieve session variables  .  Retrieving Session Variables  .  Adding Session Variables  .  Adding and Retrieving Session Variables with HttpContext  .  Adding and Retrieving Session Vairables  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to Redirect the page when the session ends
Previous Resource: How to Open a MS Access Editor using Asp.net
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use