Tuesday, July 12, 2011

Session Concept's

Session:
========
Session provides that facility to store information on servier
memory. it can support any type of object to store along with our
custom object. For every client session data store separetely
means session data is stored as per client basis.

Advantages:
==========
-it helps to maintaing user information and data to all over the applications
-it can easily be implemented and we store any kind of objects or entity\
-Stores every client data information separetely.
-Session is secure and visible from user.

Disadvantages:
==============
- Performance overhead in case of large volume of user, because
of session data stored in server memory itself.
-Overhead involved in serializing and De-serializing session
data. because in case of stateserver and sqlserver session
mode we need to seralize the object before store.

Following code is used for storing a value to session
=====================================================


Storing UserName in Session:
----------------------------

       Session["UserName"] = txtUser.Text;

Now, let see how we can retrieve values from Session


Check weather session variable null or not:
-------------------------------------------

        if (Session["UserName"] != null)
        {
            //Retrieving UserName from Session
            lblWelcome.Text = "Welcome : " + Session["UserName"];
        }
        else
        {
         //Do Something else
        }

No comments:

Post a Comment