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

Discussion in 'ASP .Net' started by _Who, Sep 18, 2008.

  1. _Who

    _Who Guest

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



    Thanks
     
    _Who, Sep 18, 2008
    #1
    1. Advertising

  2. _Who

    Guest Guest

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


    "_Who" <> дÈëÏûÏ¢
    news:...
    > Given Request.Cookies and Response.Cookies in asp.net is there any reason
    > to ever use javascript or any other method to use cookies?
    >
    >
    >
    > Thanks
    >
    >
     
    Guest, Sep 18, 2008
    #2
    1. Advertising

  3. _Who

    _Who Guest

    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.Cookies 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:...
    > 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" <> a écrit dans le message de groupe de
    > discussion : ...
    >> Given Request.Cookies and Response.Cookies in asp.net is there any reason
    >> to ever use javascript or any other method to use cookies?
    >>
    >>
    >>
    >> Thanks
    >>
    >>

    >
     
    _Who, Sep 18, 2008
    #3
  4. _Who

    _Who Guest

    <> wrote in message
    news:...
    > 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" <> дÈëÏûÏ¢
    > news:...
    >> Given Request.Cookies and Response.Cookies in asp.net is there any reason
    >> to ever use javascript or any other method to use cookies?
    >>
    >>
    >>
    >> Thanks
    >>
    >>
     
    _Who, Sep 18, 2008
    #4
  5. _Who

    _Who Guest

    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:...
    > 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" <> a écrit dans le message de groupe de
    > discussion : ...
    >> 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.Cookies 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

    >
    >
    >
     
    _Who, Sep 18, 2008
    #5
  6. "_Who" <> wrote in message
    news:%...
    > 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.Cookies to read cookies server side and
    Resquest.Cookies to set them. Personally I rarely do the clientside thing
    its usually server side.

    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Sep 18, 2008
    #6
  7. _Who

    _Who Guest

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

    Thanks

    "Anthony Jones" <> wrote in message
    news:...
    > "_Who" <> wrote in message
    > news:%...
    >> 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.Cookies to read cookies server side and
    > Resquest.Cookies to set them. Personally I rarely do the clientside
    > thing its usually server side.
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET
    >
     
    _Who, Sep 18, 2008
    #7
  8. _Who

    _Who Guest

    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:...
    >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" <> a écrit dans le message de groupe de
    > discussion : #...
    >> 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:...
    >>> 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" <> a écrit dans le message de groupe
    >>> de discussion : ...
    >>>> 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.Cookies 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
    >>>
    >>>
    >>>

    >>
    >>

    >
     
    _Who, Sep 18, 2008
    #8
    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. Alex Nitulescu

    Response.Cookies vs Request.Cookies

    Alex Nitulescu, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,580
    Hans Kesting
    Feb 3, 2005
  2. Abhishek Saksena
    Replies:
    7
    Views:
    364
    Maxim Yegorushkin
    Aug 10, 2005
  3. __PPS__
    Replies:
    3
    Views:
    1,538
    Alf P. Steinbach
    Nov 9, 2005
  4. Jimmy
    Replies:
    3
    Views:
    461
    John Carson
    Jun 30, 2006
  5. Cal Who

    Response.cookies vs Request.cookies

    Cal Who, Dec 5, 2009, in forum: ASP .Net
    Replies:
    7
    Views:
    1,533
    Gregory A. Beamer
    Dec 10, 2009
Loading...

Share This Page