recitation4 notes

recitation4 notes - 6.170Tutorial4- Prerequisites 1....

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
6.170 Tutorial 4 - Sessions and Authentication Prerequisites 1. Having rails installed is recommended. Goals of this Tutorial 1. Understand the basics of cookies and sessions and how to use them in rails. 2. Basic Authentication mechanisms in rails. Resources Topic 1: Cookies A cookie is a piece of text that a website (web server) can store on a user's hard disk. Cookies allow a website to store information on a user's machine and later retrieve it. When the user browses the same website in the future, the data stored in the cookie can be retrieved by the website to notify the website of the user's previous activity. The data is stored as key­value pairs. For example, a website might generate a unique ID number for each visitor and store the ID number on each user's machine using a cookie file. When your browser sends a request to a webserver it will look on your machine for a cookie file that the same web server has set. If it finds a cookie file, your browser will send all the key­value pairs along with the request. The web server will receive the request and be able to access the cookie data. It will be able to use these cookies to gather information about the user. Additionally, the web server can send extra information with the cookie such as expiration date or path (so the site can have different cookie values with different parts of the site). In the broadest sense, a cookie allows a site to store state information on your machine. This information lets a web server remember what state your browser is in. An ID is one simple piece of state information ­­ if an ID exists on your machine, the site knows that you have visited before. The state is, "Your browser has visited the site at least one time," and the site knows your ID from that visit. Things to keep in mind : People often share machines, cookies are easily (and often) e rased, people have multiple machines. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon