Cookies and Code-Behind?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack

    #1

    Cookies and Code-Behind?

    Hello,

    Will Cookies work in a code-behind aspx and aspx.vb page?

    I am trying to set a cookie on one page and the read it on another page.

    If anyone can help, let me know.

    Thanks in advance for your time,

    Jack


  • Kevin Kenny

    #2
    Re: Cookies and Code-Behind?

    Jack wrote:
    [color=blue]
    >Hello,
    >
    >Will Cookies work in a code-behind aspx and aspx.vb page?
    >
    >I am trying to set a cookie on one page and the read it on another page.
    >
    >If anyone can help, let me know.
    >
    >Thanks in advance for your time,
    >
    >Jack
    >
    >
    >
    >[/color]
    Jack,

    Cookies will work just fine in web forms that use code behind. Take care
    though to check for null values before attempting to read a cookie.

    e.g.

    if(Request.Cook ies["Visited"] != null) {
    string theCookie = Request.Cookies["Visited"];
    }
    else {
    Request.Cookies["Visited"] = "MyCookieValue" ;
    }

    Apologies for the C# but my VB is rusty though I think you should get
    the general idea.

    HTH
    Kev



    Comment

    • Natty Gur

      #3
      Re: Cookies and Code-Behind?

      hi,

      you can find VB sample at :


      Natty Gur, CTO
      Dao2Com Ltd.
      34th Elkalay st. Raanana
      Israel , 43000
      Phone Numbers:
      Office: +972-(0)9-7740261
      Fax: +972-(0)9-7740261
      Mobile: +972-(0)58-888377


      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...