Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP Cookies. Cookies are small files that are stored in the visitor's browser. Cookies can be used to identify return visitors, keep a user logged into.

Similar presentations


Presentation on theme: "PHP Cookies. Cookies are small files that are stored in the visitor's browser. Cookies can be used to identify return visitors, keep a user logged into."— Presentation transcript:

1 PHP Cookies

2 Cookies are small files that are stored in the visitor's browser. Cookies can be used to identify return visitors, keep a user logged into a website indefinitely, track the time of the user's last visit, and much more. Cookies accept seven different arguments, but only the "name" is required. (Keep in mind that all values are stored on the visitor's computer, so the data is not private. Never store passwords in cookies, for example!)

3 ArgumentDescription nameName of the Cookie valueValue of the Cookie expireTime When Cookie Expires (Unix Timestamp) (If "0", Or Omitted, Cookie Will Expire When Browser Closes) (Set to Client's Time, Not Server's) pathServer Path Where Cookie Is Available (If Path Is the Root Directory, Cookie Is Available In Entire Domain) (Default Value Is Current Directory) domainDomain That Cookie Is Available secureIndicates That Cookie Should Only Be Transmitted Over a Secure HTTPS Connection From Client httponlyWhen TRUE, Cookie Is Only Accessible Through HTTP Protocol

4 PHP allows you to create, retrieve and update cookies. The setcookie() function is used to first create a cookie. This function must be run before any other data is sent to the browser, such as the opening tag or random whitespace. The syntax is: setcookie(name, value, expire, path, domain);

5

6 Retrieving the "value" that is stored in our cookie


Download ppt "PHP Cookies. Cookies are small files that are stored in the visitor's browser. Cookies can be used to identify return visitors, keep a user logged into."

Similar presentations


Ads by Google