Comprehensive notes on HTTP cookies and their role in web development, covering how cookies work, the HTTP request-response cycle, session management, and client-server communication. Includes explanations of cookie types (session cookies, persistent cookies, secure cookies, HTTP-only cookies), cookie attributes (expiry, domain, path, SameSite), the difference between cookies, sessions, and tokens, and common use cases like authentication, tracking, and shopping carts. Also touches on web security concerns such as cookie hijacking and cross-site scripting (XSS). Clear explanations and structured examples make this ideal for exam preparation, assignments, and quick revision. Perfect for students studying Web Development, Computer Science, IT, or Media & Communication courses covering internet technologies.
Download HTTP Cookies Explained: Session Management, Types & Web Security – Complete Notes and more Slides Information Technology in PDF only on Docsity!
COOKIES HTTP STATE MANAGEMENT MECHANISM OUR TEAM Bibek Subedi, 066 act 506 Jivan Nepali, 066 ect 517 Dinesh Subedi, 066 act 512 Laxmi Kadariya, 066 ct 518 June 19, 2013 INTRODUCTION * A “cookie” is a small piece of information sent by a web server to store on a web browser so it can later be read back from that browser. This is useful for having the browser remember some specific information. "Cookies were designed to be a reliable mechanism for websites to remember the state of the website or activity the user had taken in the past * Although cookies cannot carry viruses, and cannot install malware on the host computer, tracking cookies and especially third-party tracking cookies are commonly used as ways to compile long-term records of individuals’ browsing histories — Privacy Concern PURPOSE OF COOKIES * Cookies make the interaction between users and web sites faster and easier « Web sites often use cookies of the purpose of collecting demographic information about their users, * Cookies enable web sites to monitor their users’ web surfing habits and profile them for marketing purposes «With the increasing commercial applications of the Internet, it was probably inevitable that cookies would quickly be utilized for advertising purposes. «Since cookies can be matched to the profile of a user’s interests and browsing habits, they are a natural tool for the “targeting” of advertisements to individual users, SYNTAX & SEMANTICS OF COOKIES |. Cookie Name 3. Cookie Version public String getName(); public String getVersion(); public void setName(String name); pulic void setVersion(String domain); 2. Cookie Value '. Cookie Age public String getValue(); public in getMaxAge(); public void setValue(String value); public void setMaxAge(int lifetime); EXAMPLE- SYNTAX & SEMANTICS (Java) Creating a Cookie Step 1: Create a Cookie instance by calling the Constructor Cookie cookie = new Cookie() Step 2: Set the name and value of the Cookie cookie.setName("ID"); cookie.setValue(5); (Both step can be done directly using Cookie cookie = new Cookie(“ID", 5) Step 3: Set and maximum age and version of Cookie cookie.setMaxAge(2500); cookie.setVersion(1); Step 4: Finally add the cookie object to the response object Response.addCookie(cookie); WORKING PRINCIPLE: usee-seaver INTERACTION « Suppose Susan, who always accesses the Web using Internet Explorer from her home PC, contacts amazon.com for the first time. « Let us suppose that in the past she has already visited the eBay site — ebay.com. * When the HTTP request comes in the Amazon’s web server, it creates unique Identification number entry in backend database that is indexed by the Identification number for Susan WORKING PRINCIPLE conn... server usual http request msg Amozon server usual http response | creates ID *| Set-cookie: 1678] 1678 for user create cookie= access = specific «| Usual http response msg} action ; s usual request poli Be 1678” ook. , ae — Figure: Keeping user ‘state — spectific ‘ ‘ using cookies PRIVACY CONSIDERATIONS * Third party cookies if a user visits a site that contains content from a third party and then later visits another site that contains content from the same third party, the third party can track the user between the two sites * User controls User agents SHOULD provide users with a mechanism for managing the cookies stored in the cookie store * Expiration dates Although servers can set the expiration date for cookies to the distant future, most user agents do not actually retain cookies for multiple decades SECURITY CONSIDERATIONS * Ambient authority * Clear text * Session identifier *" Weak confidentiality « Weak integrity COOKIE AUTHENTICATION GUIDELINES CONTD... «(Whenever possible) Tie cookie authentication to an IP address (part or all of the IP address) * Adding “salt” to your cookie (e.g. hashed http header of a particular browser, MAC address) * Re-authenticate whenever critical decisions are made * Over write tokens upon logout. " Consider using server side cache to store session information, only retain an index to the cache on the client side (also use ‘booby trapped’ indices)