Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies?

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

    Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies?

    Given Request.Cookies and Response.Cookie s in asp.net is there any reason to
    ever use javascript or any other method to use cookies?



    Thanks


  • Guest's Avatar

    #2
    Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

    eg :if you want to save the layout of the ajax page.


    "_Who" <CalWhoNOSPAN@r oadrunner.comд ÈëÏûÏ¢
    news:eyp718SGJH A.536@TK2MSFTNG P02.phx.gbl...
    Given Request.Cookies and Response.Cookie s in asp.net is there any reason
    to ever use javascript or any other method to use cookies?
    >
    >
    >
    Thanks
    >
    >

    Comment

    • Patrice

      #3
      Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

      For example if you have to set them client side... Not sure what is the goal
      of this question though ? IMO in most cases you'll use server side code if
      what you want is a confirmation that what you does is quite standard...

      --
      Patrice

      "_Who" <CalWhoNOSPAN@r oadrunner.coma écrit dans le message de groupe de
      discussion : eyp718SGJHA.536 @TK2MSFTNGP02.p hx.gbl...
      Given Request.Cookies and Response.Cookie s in asp.net is there any reason
      to ever use javascript or any other method to use cookies?
      >
      >
      >
      Thanks
      >
      >

      Comment

      • _Who

        #4
        Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

        There is much JavaScript cookie code on the Internet and in books, that
        shows how to write, read, and take apart what is read.
        I have some saved. I was wondering if there is any reason for me to save
        that.

        Also, I work alone so it would be valuable to hear that using
        Request.Cookies and Response.Cookie s is a good approach not withstanding all
        the code that uses document.cookie .

        It's confusing. For example your statement: "For example if you have to set
        them client side... "
        Is there some reason to do that?

        In fact, I'm looking at a 75-line code that is used to display the number of
        visits by the person to the site. It uses document.cookie and JavaScript. Is
        that the way you'd do it?

        Thanks for helping


        "Patrice" <http://www.chez.com/scribe/wrote in message
        news:0AAB1085-E4DD-4BBF-A480-6B46814665B7@mi crosoft.com...
        For example if you have to set them client side... Not sure what is the
        goal of this question though ? IMO in most cases you'll use server side
        code if what you want is a confirmation that what you does is quite
        standard...
        >
        --
        Patrice
        >
        "_Who" <CalWhoNOSPAN@r oadrunner.coma écrit dans le message de groupe de
        discussion : eyp718SGJHA.536 @TK2MSFTNGP02.p hx.gbl...
        >Given Request.Cookies and Response.Cookie s in asp.net is there any reason
        >to ever use javascript or any other method to use cookies?
        >>
        >>
        >>
        >Thanks
        >>
        >>
        >

        Comment

        • _Who

          #5
          Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?


          <chsword@126.co mwrote in message
          news:59927170-C0D7-4828-8F30-16FB29ECBD06@mi crosoft.com...
          eg :if you want to save the layout of the ajax page.
          I don't think I'm there yet. I mean I haven't gotten to ajax yet.

          Thanks

          >
          >
          "_Who" <CalWhoNOSPAN@r oadrunner.comд ÈëÏûÏ¢
          news:eyp718SGJH A.536@TK2MSFTNG P02.phx.gbl...
          >Given Request.Cookies and Response.Cookie s in asp.net is there any reason
          >to ever use javascript or any other method to use cookies?
          >>
          >>
          >>
          >Thanks
          >>
          >>

          Comment

          • Patrice

            #6
            Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

            IMO don't save something you find easily on the web. Knowing you can is
            enough and you'll have no problem to find this again when needed...

            You have likely more than this cookie to produce an approximate number of
            current users on your site and no I wouldn't do this way (you have a cookie
            though for your ASP.NET session).

            I remember to have done this at least one time (setting the cookie client
            side) but I don't remember what was the purpose.

            I would do things the other way round. Instead of asking why you would do
            something in a particular way, tell rather what you are trying to do and
            someone will likely give - if not the mythical "best way" - at least a
            possible logical way to do that...

            Do you want to display on your page an approximate number of users currently
            visiting the site ?

            --
            Patrice

            "_Who" <CalWhoNOSPAN@r oadrunner.coma écrit dans le message de groupe de
            discussion : Ofvme1YGJHA.373 6@TK2MSFTNGP06. phx.gbl...
            There is much JavaScript cookie code on the Internet and in books, that
            shows how to write, read, and take apart what is read.
            I have some saved. I was wondering if there is any reason for me to save
            that.
            >
            Also, I work alone so it would be valuable to hear that using
            Request.Cookies and Response.Cookie s is a good approach not withstanding
            all the code that uses document.cookie .
            >
            It's confusing. For example your statement: "For example if you have to
            set them client side... "
            Is there some reason to do that?
            >
            In fact, I'm looking at a 75-line code that is used to display the number
            of visits by the person to the site. It uses document.cookie and
            JavaScript. Is that the way you'd do it?
            >
            Thanks for helping


            Comment

            • _Who

              #7
              Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

              The answer your last question is yes.

              But I find mostly cookie code on the internet uses JavaScript and from your
              reply I now know that with ASP.NET that is not the way to go. For that I
              thank you.


              "Patrice" <http://www.chez.com/scribe/wrote in message
              news:F5B2E7A6-318D-4118-AE8C-9548470E90CE@mi crosoft.com...
              IMO don't save something you find easily on the web. Knowing you can is
              enough and you'll have no problem to find this again when needed...
              >
              You have likely more than this cookie to produce an approximate number of
              current users on your site and no I wouldn't do this way (you have a
              cookie though for your ASP.NET session).
              >
              I remember to have done this at least one time (setting the cookie client
              side) but I don't remember what was the purpose.
              >
              I would do things the other way round. Instead of asking why you would do
              something in a particular way, tell rather what you are trying to do and
              someone will likely give - if not the mythical "best way" - at least a
              possible logical way to do that...
              >
              Do you want to display on your page an approximate number of users
              currently visiting the site ?
              >
              --
              Patrice
              >
              "_Who" <CalWhoNOSPAN@r oadrunner.coma écrit dans le message de groupe de
              discussion : Ofvme1YGJHA.373 6@TK2MSFTNGP06. phx.gbl...
              >There is much JavaScript cookie code on the Internet and in books, that
              >shows how to write, read, and take apart what is read.
              >I have some saved. I was wondering if there is any reason for me to save
              >that.
              >>
              >Also, I work alone so it would be valuable to hear that using
              >Request.Cookie s and Response.Cookie s is a good approach not withstanding
              >all the code that uses document.cookie .
              >>
              >It's confusing. For example your statement: "For example if you have to
              >set them client side... "
              >Is there some reason to do that?
              >>
              >In fact, I'm looking at a 75-line code that is used to display the number
              >of visits by the person to the site. It uses document.cookie and
              >JavaScript. Is that the way you'd do it?
              >>
              >Thanks for helping
              >
              >
              >

              Comment

              • Anthony Jones

                #8
                Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

                "_Who" <CalWhoNOSPAN@r oadrunner.comwr ote in message
                news:%23Ko9VOZG JHA.4992@TK2MSF TNGP04.phx.gbl. ..
                The answer your last question is yes.
                >
                But I find mostly cookie code on the internet uses JavaScript and from
                your reply I now know that with ASP.NET that is not the way to go. For
                that I thank you.
                >
                I'm not sure what its you are seeing. It is possible for cookies to be used
                by both client and server. You use Javascript clientside to read and set
                cookie info, you use Response.Cookie s to read cookies server side and
                Resquest.Cookie s to set them. Personally I rarely do the clientside thing
                its usually server side.

                --
                Anthony Jones - MVP ASP/ASP.NET

                Comment

                • Patrice

                  #9
                  Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

                  A basic approach is to use the session start and end event (see
                  global.asax). Increase an application variable when a session starts and
                  decrease the application variable when the session ends.

                  That said the end event of a session doesn't happen in some cases (when
                  using the SQL Server provider) or is/was not known to be terribly reliable
                  so my personal approach would be :
                  - to keep track in an application variable of each session I heard about
                  including a timestamp
                  - counting recently used session (whatever criteria you want as you have a
                  timestamp) gives the number of users
                  - you can remove old sessions records from the list and you don't care about
                  session events happening or not

                  In all cases this is just indicative as http is stateless and you don't know
                  immediately when a user closes his browser. Some are doing a server side
                  call to close the session from a client side event but I never found it was
                  worth the trouble to go against http nature.

                  You should find lot of resources about this on Google (especially #1 and #3,
                  not sure about #2). In all cases, isolete this code so that you'll be able
                  to change the method you are suing at will without changing anyhting in the
                  rest of your code.

                  --
                  Patrice

                  "_Who" <CalWhoNOSPAN@r oadrunner.coma écrit dans le message de groupe de
                  discussion : #Ko9VOZGJHA.499 2@TK2MSFTNGP04. phx.gbl...
                  The answer your last question is yes.
                  >
                  But I find mostly cookie code on the internet uses JavaScript and from
                  your reply I now know that with ASP.NET that is not the way to go. For
                  that I thank you.
                  >
                  >
                  "Patrice" <http://www.chez.com/scribe/wrote in message
                  news:F5B2E7A6-318D-4118-AE8C-9548470E90CE@mi crosoft.com...
                  >IMO don't save something you find easily on the web. Knowing you can is
                  >enough and you'll have no problem to find this again when needed...
                  >>
                  >You have likely more than this cookie to produce an approximate number of
                  >current users on your site and no I wouldn't do this way (you have a
                  >cookie though for your ASP.NET session).
                  >>
                  >I remember to have done this at least one time (setting the cookie client
                  >side) but I don't remember what was the purpose.
                  >>
                  >I would do things the other way round. Instead of asking why you would do
                  >something in a particular way, tell rather what you are trying to do and
                  >someone will likely give - if not the mythical "best way" - at least a
                  >possible logical way to do that...
                  >>
                  >Do you want to display on your page an approximate number of users
                  >currently visiting the site ?
                  >>
                  >--
                  >Patrice
                  >>
                  >"_Who" <CalWhoNOSPAN@r oadrunner.coma écrit dans le message de groupe de
                  >discussion : Ofvme1YGJHA.373 6@TK2MSFTNGP06. phx.gbl...
                  >>There is much JavaScript cookie code on the Internet and in books, that
                  >>shows how to write, read, and take apart what is read.
                  >>I have some saved. I was wondering if there is any reason for me to save
                  >>that.
                  >>>
                  >>Also, I work alone so it would be valuable to hear that using
                  >>Request.Cooki es and Response.Cookie s is a good approach not withstanding
                  >>all the code that uses document.cookie .
                  >>>
                  >>It's confusing. For example your statement: "For example if you have to
                  >>set them client side... "
                  >>Is there some reason to do that?
                  >>>
                  >>In fact, I'm looking at a 75-line code that is used to display the
                  >>number of visits by the person to the site. It uses document.cookie and
                  >>JavaScript. Is that the way you'd do it?
                  >>>
                  >>Thanks for helping
                  >>
                  >>
                  >>
                  >
                  >

                  Comment

                  • _Who

                    #10
                    Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

                    I'm probably finding code for users not doing ASP.NET

                    Thanks

                    "Anthony Jones" <AnthonyWJones@ yadayadayada.co mwrote in message
                    news:ujFZfZaGJH A.5572@TK2MSFTN GP03.phx.gbl...
                    "_Who" <CalWhoNOSPAN@r oadrunner.comwr ote in message
                    news:%23Ko9VOZG JHA.4992@TK2MSF TNGP04.phx.gbl. ..
                    >The answer your last question is yes.
                    >>
                    >But I find mostly cookie code on the internet uses JavaScript and from
                    >your reply I now know that with ASP.NET that is not the way to go. For
                    >that I thank you.
                    >>
                    >
                    I'm not sure what its you are seeing. It is possible for cookies to be
                    used by both client and server. You use Javascript clientside to read and
                    set cookie info, you use Response.Cookie s to read cookies server side and
                    Resquest.Cookie s to set them. Personally I rarely do the clientside
                    thing its usually server side.
                    >
                    --
                    Anthony Jones - MVP ASP/ASP.NET
                    >

                    Comment

                    • _Who

                      #11
                      Re: Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

                      Debugging once I noticed that the session end event was not raised.

                      Thanks for the info below.



                      "Patrice" <http://www.chez.com/scribe/wrote in message
                      news:7FCF36F0-5152-4223-99B5-2E63A5FE9D06@mi crosoft.com...
                      >A basic approach is to use the session start and end event (see
                      >global.asax) . Increase an application variable when a session starts and
                      >decrease the application variable when the session ends.
                      >
                      That said the end event of a session doesn't happen in some cases (when
                      using the SQL Server provider) or is/was not known to be terribly reliable
                      so my personal approach would be :
                      - to keep track in an application variable of each session I heard about
                      including a timestamp
                      - counting recently used session (whatever criteria you want as you have a
                      timestamp) gives the number of users
                      - you can remove old sessions records from the list and you don't care
                      about session events happening or not
                      >
                      In all cases this is just indicative as http is stateless and you don't
                      know immediately when a user closes his browser. Some are doing a server
                      side call to close the session from a client side event but I never found
                      it was worth the trouble to go against http nature.
                      >
                      You should find lot of resources about this on Google (especially #1 and
                      #3, not sure about #2). In all cases, isolete this code so that you'll be
                      able to change the method you are suing at will without changing anyhting
                      in the rest of your code.
                      >
                      --
                      Patrice
                      >
                      "_Who" <CalWhoNOSPAN@r oadrunner.coma écrit dans le message de groupe de
                      discussion : #Ko9VOZGJHA.499 2@TK2MSFTNGP04. phx.gbl...
                      >The answer your last question is yes.
                      >>
                      >But I find mostly cookie code on the internet uses JavaScript and from
                      >your reply I now know that with ASP.NET that is not the way to go. For
                      >that I thank you.
                      >>
                      >>
                      >"Patrice" <http://www.chez.com/scribe/wrote in message
                      >news:F5B2E7A 6-318D-4118-AE8C-9548470E90CE@mi crosoft.com...
                      >>IMO don't save something you find easily on the web. Knowing you can is
                      >>enough and you'll have no problem to find this again when needed...
                      >>>
                      >>You have likely more than this cookie to produce an approximate number
                      >>of current users on your site and no I wouldn't do this way (you have a
                      >>cookie though for your ASP.NET session).
                      >>>
                      >>I remember to have done this at least one time (setting the cookie
                      >>client side) but I don't remember what was the purpose.
                      >>>
                      >>I would do things the other way round. Instead of asking why you would
                      >>do something in a particular way, tell rather what you are trying to do
                      >>and someone will likely give - if not the mythical "best way" - at least
                      >>a possible logical way to do that...
                      >>>
                      >>Do you want to display on your page an approximate number of users
                      >>currently visiting the site ?
                      >>>
                      >>--
                      >>Patrice
                      >>>
                      >>"_Who" <CalWhoNOSPAN@r oadrunner.coma écrit dans le message de groupe
                      >>de discussion : Ofvme1YGJHA.373 6@TK2MSFTNGP06. phx.gbl...
                      >>>There is much JavaScript cookie code on the Internet and in books, that
                      >>>shows how to write, read, and take apart what is read.
                      >>>I have some saved. I was wondering if there is any reason for me to
                      >>>save that.
                      >>>>
                      >>>Also, I work alone so it would be valuable to hear that using
                      >>>Request.Cook ies and Response.Cookie s is a good approach not
                      >>>withstandi ng all the code that uses document.cookie .
                      >>>>
                      >>>It's confusing. For example your statement: "For example if you have to
                      >>>set them client side... "
                      >>>Is there some reason to do that?
                      >>>>
                      >>>In fact, I'm looking at a 75-line code that is used to display the
                      >>>number of visits by the person to the site. It uses document.cookie and
                      >>>JavaScript . Is that the way you'd do it?
                      >>>>
                      >>>Thanks for helping
                      >>>
                      >>>
                      >>>
                      >>
                      >>
                      >

                      Comment

                      Working...