Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

Cookies

  • A cookie is a piece of information set by an HTTP server and sent to a web client within an HTTP response for storage by the client.
  • Cookies are associated with a particular website, and each time a client requests a page from a website for which it has received & stored a cookie, it includes the corresponding cookie’s data within its HTTP request.
  • HTTP is a stateless protocol meaning that each HTTP transaction between a client & server has no ‘memory’ of any previous transactions.
  • The purpose of cookies is to allow state, or knowledge of previous events, to be introduced into HTTP transactions.
  • The way a web server sends a cookie to a client is via the Set-Cookie header of an HTTP response:
    HTTP/1.1 200 OK
    Date: Wed, 3 Aug 2011 23:59:59 GMT
    Content-Type: text/html
    Set-Cookie: cookie=cookieValue
    Host: www.educator.com
  • Cookie data is in the form of name-value pairs.
  • Each time a client requests a page from a website for which it has a cookie, it sends the cookie’s information back to the server using the Cookie HTTP request header:
    GET /index.html HTTP/1.1
    Host: www.educator.com
    Cookie: cookie=cookieValue
  • setcookie() is a built-in PHP function that allows a script to send a cookie to a web client. It must be called before any of a script’s output is generated.
  • Cookies have several attributes that can be set which determine whether a client sends a particular cookie in its request for a page from a particular website:
    • domain – specifies the domain which a cookie applies to
    • path – specifies a particular path within a domain that the cookie applies to
    • expires – the data & time when a cookie is no longer valid
  • $_COOKIE is a superglobal associative array containing any cookie name/value pairs sent by a client in its request for a PHP script.
  • Additional Resources:

Cookies

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

Advanced PHP Training with MySQL