
Cookie Protocol Server Sets Cookies in Response Header
Learn about how the Cookie Protocol Server sets cookies in the response header, including the session ID, expiration time, and handling in subsequent requests. Explore examples of session management in Rails, with insights on Easter Egg Controller and Views. Dive into CS 142 Lecture Notes on cookies with detailed explanations and visual aids.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Cookie Protocol Server sets cookies in response header: Set-Cookie: session=0x4137f; Expires=Wed, 09 Jun 2012 10:18:14 GMT Name Value Expiration Time Browser returns cookies in headers of later requests: Cookie: session=0x4137fd6a CS 142 Lecture Notes: Cookies Slide 1
Easter Egg Controller class RailsIntroController < ApplicationController def hello @warning = false if session[:count] == nil then session[:count] = 0 end session[:count] = session[:count] + 1 if (session[:count] >= 3) then session[:count] = 0 @warning = true end ... end CS 142 Lecture Notes: Cookies Slide 2
Easter Egg View <%@title = "Hello, User"%> <p> This page was fetched at <%= Time.now() %> </p> <% if @warning %> <p> <b>HEY!</b> Don't you have anything better to do than just redisplaying me over and over? </p> <% end %> CS 142 Lecture Notes: Cookies Slide 3
CS 142 Lecture Notes: Cookies Slide 4