Page 291 - DCAP408_WEB_PROGRAMMING
P. 291

Unit 13: ASP Cookies and Caching




          The term cookies has no special significance. It is just as name. When a user requests a page, an  Notes
          HTTP request is sent to the server. The request includes a header that defines several pieces of
          information, including the page being requested. The server returns an HTTP response that also
          includes a header.




             Notes  The header contains information about the document being returned, including its
             MIME type.
           These headers all contain one or more fields of information in a basic format.
                 FieldName: Information
          Cookie information is shared between the client browser and a server using fields in the HTTP
          headers. When the user requests a page for the first time, a cookie (or more than one cookie) can be
          stored in the browser by a set-cookie entry in the header of the response from the server. The set-cookie
          field includes the information to be stored in the cookie along with several optional pieces of information,
          including an expiry date, path, and server information and if the cookie requires security.

          Then, when the user requests a page in the future, if a matching cookie is found among all the
          stored cookies, the browser sends a cookie field to the server in a request header. The header
          will contain the information stored in that cookie.



             Did u know?  How Cookie use the syntax?
             The set-cookie and cookie fields use syntax to transfer significant information between
             client and server.

          13.2.1 Setting a Cookie

          Syntax

                 Set-cookie:  NAME=value;  EXPIRES=date;  PATH=path;  DOMAIN=domain;  SECURE
          The NAME=value  is the only required  piece of  information that  must be included  in  the
          set-cookie field. All other entries are optional.
             Name           Description
             NAME=value     Specifies the name of the cookie.
             EXPIRES=date   Specifies the expiry date of the cookie. After this date the cookie will no longer
                            be  stored  by  the  client  or  sent  to  the  server.  DATE  takes  the  form  WDY,
                            DD-MON-YY HH:MM:SS  GMT.  By  default, the  value of expires is  set to the
                            end of current Navigator session.
             PATH=path      Specifies the path portion of the URLs for which the cookie is valid. If the URL
                            matches both the PATH and the DOMAIN, then the cookie is sent to the server
                            in the  request header.  If left  unset, the value of  the PATH  is the  same as the
                            document that set the cookie.
             DOMAIN=domain   Specifies  the  domain  portion  of  the URLs  for which the  cookie  is  valid. The
                            default value for  this attributes is  the  domain of the current document setting
                            the cookie.
             SECURE         Specifies  that  the  cookie  should  only  be transmitted  over  a  secure  link  (i.e.,
                            HTTP servers using SSL protocol known as HTTPS server).





                                           LOVELY PROFESSIONAL UNIVERSITY                                   285
   286   287   288   289   290   291   292   293   294   295   296