Cookie and Session Cookie Questions.

Discussion in 'ASP .Net' started by Shapper, Apr 27, 2005.

  1. Shapper

    Shapper Guest

    Hello,

    I am working on an ASP.NET / VB web page.

    How can I set a cookie in my visitor computer and also a Session Cookie?
    And how can I retrieve their values?

    I will run it when page loads.

    Thank You,
    Miguel
    Shapper, Apr 27, 2005
    #1
    1. Advertising

  2. Shapper

    Mona Guest

    Hi Miguel,

    You can use the Response object of ASP.NET to write cookies.
    The Response object has a Cookies collection to which you add the
    cookies you want to write to the browser.

    You can add cookies to the Response.Cookies collection in a couple of ways.
    The following example shows two methods to accomplish the task:
    Response.Cookies("userName").Value = "mike"
    Response.Cookies("userName").Expires = DateTime.Now.AddDays(1)

    Dim aCookie As New HttpCookie("lastVisit")
    aCookie.Value = DateTime.Now.ToString
    aCookie.Expires = DateTime.Now.AddDays(1)
    Response.Cookies.Add(aCookie)Following is a link which discusses this topic in detail:

    [Basics of Cookies in ASP.NET]
    http://msdn.microsoft.com/library/d...s/dv_vstechart/html/vbtchASPNETCookies101.asp
    It has various links which also talk about Session management and Cookies.HTHMona[Grapecity]"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message news:...
    > Hello,
    >
    > I am working on an ASP.NET / VB web page.
    >
    > How can I set a cookie in my visitor computer and also a Session Cookie?
    > And how can I retrieve their values?
    >
    > I will run it when page loads.
    >
    > Thank You,
    > Miguel
    >
    Mona, Apr 27, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben
    Replies:
    3
    Views:
    5,790
    Steven Cheng[MSFT]
    Jun 3, 2004
  2. =?Utf-8?B?RWFybCBUZWlncm9i?=

    Does session cookie persist when after session times out?

    =?Utf-8?B?RWFybCBUZWlncm9i?=, Jul 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    592
    Mike Newton
    Jul 28, 2004
  3. =?Utf-8?B?amVycnkueHVkZGQ=?=

    session cookie and presist cookie?

    =?Utf-8?B?amVycnkueHVkZGQ=?=, Mar 7, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    467
    =?Utf-8?B?RGFycmVuIEtvcHA=?=
    Mar 8, 2006
  4. Joseph

    authentication cookie vs session cookie

    Joseph, Aug 8, 2003, in forum: ASP .Net Security
    Replies:
    4
    Views:
    380
    Yan-Hong Huang[MSFT]
    Aug 12, 2003
  5. Matt

    session cookie vs. regular cookie

    Matt, Jan 24, 2004, in forum: ASP General
    Replies:
    1
    Views:
    755
    Blair Bonnett
    Jan 25, 2004
Loading...

Share This Page