Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cookies in PHP CPTE 212 4/7/2015 John Beckett. Two Types of Cookies A cookie is data saved on the client computer Temporary – saved in RAM in the workstation.

Similar presentations


Presentation on theme: "Cookies in PHP CPTE 212 4/7/2015 John Beckett. Two Types of Cookies A cookie is data saved on the client computer Temporary – saved in RAM in the workstation."— Presentation transcript:

1 Cookies in PHP CPTE 212 4/7/2015 John Beckett

2 Two Types of Cookies A cookie is data saved on the client computer Temporary – saved in RAM in the workstation –Vanish when the browser is exited Persistent – saved on the hard drive of the workstation –Made persistent by giving them a date in the future –Deleted by giving them a date in the past

3 Names and Values Names may include [], which means you can have an array of arrays (2-dimensional array) in PHP but work with the single-dimensional array structure of cookies Cookies may not include certain characters such as a semicolon, but PHP auto-translates so you don’t see this limitation

4 Creating Cookies setcookie(name,value,expires,path,domain,secure) setcookie() must appear before anything else in your PHP code including spaces. Name and Value are required Other parameters are optional –Expires makes a cookie persistent –Path allows access by scripts in other directories –Domain allows other hosts to access –Secure requires SSL/https

5 $_COOKIE[] autoglobal Fetches a copy of all available cookies before any are set If you programmatically put a value into this array, it doesn’t go into the actual cookie but only into the autoglobal


Download ppt "Cookies in PHP CPTE 212 4/7/2015 John Beckett. Two Types of Cookies A cookie is data saved on the client computer Temporary – saved in RAM in the workstation."

Similar presentations


Ads by Google