lecture27

lecture27 - PIC 40A Lecture 27: PHP Cookies, Session...

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

View Full Document Right Arrow Icon
PIC 40A Lecture 27: PHP Cookies, Session Tracking, Regular Expressions
Background image of page 1

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

View Full DocumentRight Arrow Icon
What is a cookie? • small object of information consisting of a name and a textual value • provided by a server program • transmitted back and forth via HTTP headers • stored on a client • provides a general approach to storing information about sessions on the browser system
Background image of page 2
What kinds of information do cookies remember about previous sessions? • the websites you perused • which parts of a particular site you perused or clicked • login usernames and passwords entered • purchases and information submitted via forms
Background image of page 3

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

View Full DocumentRight Arrow Icon
Problems with Cookies • Browsers can disable them • Browsers can delete them • Cookies do not travel from one computer to another • Cookies get stale: every cookie has a lifetime
Background image of page 4
Setting a PHP Cookie • set a cookie using the function setcookie($name, $value, $expirationtime) • if $value is not given, setcookie undefines the cookie • default value for $expirationtime is 0 which means cookie is destroyed at the end of the session • $expirationtime is a timestamp and hence represents a date/time given in seconds since the UNIX epoch (1 day = 86400 seconds)
Background image of page 5

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

View Full DocumentRight Arrow Icon
Important Note on PHP Cookies • Cookies must be created/modified before any XHTML is created by the PHP document Reason: Cookies are transported in the HTTP response headers to the browser (before any part of the document body)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/15/2010 for the course PIC 40A taught by Professor Ouellette during the Winter '10 term at UCLA.

Page1 / 18

lecture27 - PIC 40A Lecture 27: PHP Cookies, Session...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online