24 Aug 2012

How to use a Session variable from a .cs file


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.SessionState;
/// <summary>
/// Summary description for Class1
/// </summary>
///IRequiresSessionState enable session in Class file
public class Class1:IRequiresSessionState
{
    public Class1()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public void getSession(string key)
    {
        if (HttpContext.Current.Session[key] != null)
        {
            string sessionID= HttpContext.Current.Session[key].ToString();
        }
    }
}