- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Cookies are text files stored on the client computer and they are kept for tracking purpose. PHP transparently supports HTTP cookies.
Your server sends some data to the visitor's browser in the form of a cookie. The browser may accept the cookie. If it does, it is stored as a plain text record on the visitor's hard drive. Now, when the visitor arrives at another page on your site, the browser sends the same cookie to the server for retrieval. Once retrieved, your server knows/remembers what was stored earlier.
The data contained in a cookie is automatically transmitted between the web browser and the web server, so CGI scripts on the server can read and write cookie values that are stored on the client.
How PHP cookies work?
HTTP/1.1 200 OK Date: Fri, 04 Feb 2000 21:03:38 GMT Server: Apache/1.3.9 (UNIX) PHP/4.0b3 Set-Cookie: name = xyz; expires = Friday, 04-Feb-07 22:03:38 GMT; path = /; domain = tutorialspoint.com Connection: close Content-Type: text/html
As you can see, the Set-Cookie header contains a name-value pair, a GMT date, a path and a domain. The name and value will be URL encoded. The “expires” field is an instruction to the browser to "forget" the cookie after the given time and date.
PHP provideS setcookie() function to set a cookie. This function requires upto six arguments and should be called before <html> tag.
- What are the differences between holography and photography?
- What are the differences between C++ and Java?
- What are the differences between C and Java?
- What are the differences between lodash and underscore?
- What are the differences between IPO and FPO?
- What are the differences between solvency and liquidity?
- What are the differences between Flutter and Xamarin?
- What are the differences between BorgBase and RapidShare?