Session
state is used to store the information at the server end. Whenever we
access the web application ,session id 128 ,256 or 512 bit generated.It
depends which algorithm web are using . There are some algorithms which
are used to encrypt and decrypt the session data.I will discuss this
algorithm in coming next tutorials. Id is generated in the form of non persistent cookie
. We can used session object to store the user specific data.You have
seen ,many website are compromised due to session attack.To improve the
performance of websites,we can use https,ssl and other protocol to
secure your web applications.Each client accessing a web application
maintains a distinct session with the web server and there is also
specific information associated with each of these sessions.Session
state is defined in the element of the web.config file.It
also stores the data specific to a user session in session variables .
Different session variables are created for each user session.Session
Id is transferred between the server and the client over to HTTP protocol using cookies.
Example:-When we open(login) your gmail account on your web browser then we can open all google account(orkut,google+,you tube,blogger,google
analytic,adsense etc.) through session id.Because i have told that
session id is transferred between the server and the client over to HTTP
Protocol using cookies.
There are some steps to implement the session state variables on the as.net web applications.
Step 1:-First
open your visual studio -->File-->New-->website-->select
ASP.NET Empty website -->OK-->open solution explorer -->Add New
Web Form -->drag and drop label,Text box and Button control on the
form as shown below:-
Step 4:- Double click on Logout button-->Write the following codes which are given below:- ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Label1.Text = Session["id"].ToString(); } protected void Button1_Click(object sender, EventArgs e) { //Session.Remove("id"); you wana remove one by one use this. Session.RemoveAll(); Response.Redirect("session.aspx"); } } Step 5:- Now Run the application (press F5)-->Fill the required field details as shown below:-
Step 6:- Now click Submit button --> you will see following output-->now click Logout button--> you will redirect to home page(destroy session).






0 comments:
Post a Comment
Get Benifits