Hi friends,
I want to know What is session and How to implement session with cookies ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted May 23, 2012, 10:08 PM
Sessions can be used to store even complex data for the user just like cookies. Actually, sessions will use cookies to store the data, unless you explicitly tell it not to. Sessions can be used easily in ASP.NET with the Session object. We will re-use the cookie example, and use sessions instead. Keep in mind though, that sessions will expire after a certain amount of minutes, as configured in the web.config file. Markup code: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
And here is the CodeBehind: using System;
using System.Data;
using System.Web;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Session["BackgroundColor"] != null)
{
ColorSelector.SelectedValue = Session["BackgroundColor"].ToString();
BodyTag.Style["background-color"] = ColorSelector.SelectedValue;
}
}
protected void ColorSelector_IndexChanged(object sender, EventArgs e)
{
BodyTag.Style["background-color"] = ColorSelector.SelectedValue;
Session["BackgroundColor"] = ColorSelector.SelectedValue;
}
}
Please refer the below link
http://asp.net-tutorials.com/state/sessions/
http://www.developertutorials.com/tutorials/java/implement-session-tracking-050611-1110/
http://www.datasprings.com/resources/articles-information/cookie-creation-session-management
Thanks