Avaricesoft’s Weblog

Just another WordPress.com weblog

Session in asp.net

Posted by avaricesoft on June 10, 2009

What is Session:

This collection holds information for a single user, so it can be used in
different pages. For example, you can use the Session collection to store the
items in the current user’s shopping basket on an e-commerce website

First you should include the Session Collection by using Clause

using System.Web.SessionState;

How to Save the Data from Session State / How to Create the Session State in asp.net 2008:

  • suppose their is a class of user’s –>save the session object of username for userclass.

userclass uc = new userclass();

Session["username"] = uc.getusername();

  • getusername() return the username of string of the above code

How to Reterieve the Data Session from State / How to Get the Date from Session State in asp.net 2008:

  • Reterieve the data in other page using Session State of username here it is:

userclass uc1 = userclass();

uc1.setusername(Session["username"].ToString());

  • setusername is the public function of userclass which takes string parameter

Remove Unsused object of the Session State:

  • you should remove the Session State manually by coding its a best practices of the programmer and client hand side and server modules.

Session.["username"] = null;

  • not remove the Session State is define because where u have to null the Session State not remove its depend upon case to case.

Session.Remove["username"]

  • if you null the Session State then its not remove so best practice is to remove the Session State not null

Thanks All.

Regards,

Muhammad Kalim (+92-333-2352452)

Manager Business Development AVARICESOFT.com

if you have any query then write the comments.. i will help u out

One Response to “Session in asp.net”

  1. RRaveen said

    Dear Friends,

    I hope you are doing well. I have launched a web site http://www.codegain.com and it is basically aimed C#,JAVA,VB.NET,ASP.NET,AJAX,Sql Server,Oracle,WPF,WCF and etc resources, programming help, articles, code snippet, video demonstrations and problems solving support. I would like to invite you as an author and a supporter. Looking forward to hearing from you and hope you will join with us soon.

    Please forward this email to all of your friends who are related IT. Send to us your feed about site also.

    Thank you
    RRaveen
    Founder CodeGain.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.