I have created a session for User Login as:
[HttpPost]
public ActionResult Index(UserLogin lc)
{
string mainconn = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(mainconn);
SqlCommand sqlcomm = new SqlCommand("UserLogin");
sqlconn.Open();
sqlcomm.Connection = sqlconn;
sqlcomm.CommandType = CommandType.StoredProcedure;
sqlcomm.Parameters.AddWithValue("@Email", lc.Email);
sqlcomm.Parameters.AddWithValue("@Password", lc.Password);
SqlDataReader sdr = sqlcomm.ExecuteReader();
if(sdr.Read())
{
FormsAuthentication.SetAuthCookie(lc.Email, true);
Session["Email"] = lc.Email.ToString();
return RedirectToAction("Welcome");
}
Now I need to use the Session variable stored here in another controller. How can I do so?
var email = Session["Email"];?