You must Sign In to post a response.
  • Category: .NET

    Difference between cookie and session

    What is session? what is cookie ? Difference between cookie and session roja
  • #724322
    [Response removed by Admin. Read forum policies.]
    I Hope To Use Full..
    And Choice The Best Answers

    php-wordpress Developer
    you can any problem to php wordpress to contact me

  • #724324

    There are several differences between Sessions and cookies.

    Cookies :

    1) Not Secure
    2) Size limitation (4KB)
    3) Stored in User Browser untill deleted.
    4) problem is User can block cookie and delete at any time
    5) Store user logins

    Sessions :

    1) Secure
    2) There is no size limitation, unlimited storage.
    3) It's not stored in user browser.
    4) problems is Close the session and also loose the session.
    5) Session will not store user login information.

    Hope this information may clear your doubts.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #724347
    Hi ,

    Session state variables are stored on the webserver by default and kept for the lifetime of entire session where as Cookies store information on client machine.If you set the expires property of HTTPCookies object they remain on client computer even after the browser is closed.

    Cookies store only small amount of information but session state variables can be used for simple type objects to complex types.


  • #724369
    A Cookie is a small piece of data stored on the user's computer. Most browsers allow only 20 cookies per site
    1) Simplicity easy to create and use in web page.

    1) Cookies functionality may be disabled on Users Browsers, so make sure before using this.
    2) Cookies are transmitted for each HTTP request/response causing over head on bandwidth.
    3) Cookies are Inappropriate for sensitive data like banking applications etc.


    protected void Button1_Click(object sender, EventArgs e)
    //Add cookies with key and name in the user's browsers
    Response.Cookies["UserId"].Value = TextBox1.Text;

    //Get back value from cookies and assign in the label control
    lblmsg.Text = Request.Cookies["UserId"].Value.ToString();

    Session is used to keep values across post back and keep values across all pages too, mean if you declare value in the session variable you can call that session value in any page of the project. Compare to other View state, hidden Field etc. Session have most popular state management control.

    session["loginuser"] = "name of the user";

    //Calling like this
    Label1.Text = Session["loginuser"].ToString();

    //Remove like this

    //Remove all session values

    Further more detail state management explanation refer my resource here

    Your Hard work never fails

  • #724373
    [Response removed by Admin. Read forum policies.]

  • #724376
    [Response removed by Admin. Read forum policies.]

  • #724612
    cookie :
    cookie are used for remember the user for some time which is allocated in coding at the time of writing code for that page in which one temporary file is send to the client which is stored and when client again comes to the website at that time along with cookie when client sends request then only server can identify that client and work on that. when cookie time expires at that time server will destroy that cookie and gives a new cookie to client.

    Session :

    session is a temporary way in which browser or server can remember the client when client can't close the browser when client close the browser then that session expires.

    different browser has it's own way to maintain session.

    I hope your problem is solved

    - Regrads
    Nayan Vyas

  • #724740
    [Response removed by Admin. Read forum policies.]

  • #724935
    [Response removed by Admin. Read forum policies.]

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.