PHP Cookies – How to Create, Set, Read & Delete a Cookie in PHP

PHP Cookies – How to set, read and delete a cookie in PHP?

HTTP is a stateless protocol. It means user sends a request, a server responds to that request without remembering the request later. To track important information (such as user preference, user activity etc.) on a website cookies are very useful. In this blog post, You are going to learn what is a cookie and How to create, set, read and delete a cookie in PHP.

What is Cookie?

Cookies are very useful to store small information in a remote browser (user browser). It’s a simple text file which stores maximum 4KB of data.

Cookies are created by a browser on the request of a server (as per program logic). Once a cookie is created on a user browser, the browser sends that cookie information back to the server using HTTP Header.

How to Store & Retrieve an Array Value in a Cookie

How to store and retrieve an array value in a cookie.  Cookies can only store string values. You cannot store an array directly into a cookie. In this article, We’ll discuss how to store and retrieve an array value from a cookie.

My previous post related to Cookies.

1. How to create, read, update and delete  a cookie in PHP

Subscribe Our Tutorials

Get Latest Updates on Facebook

2. How to set a cookie on multiple subdomains


How to Set Cookies for Multiple Subdomains

How to set cookies for multiple subdomains. In this tutorial, You are going to learn how to set and read a cookie from multiple subdomains.

HTTP is a stateless protocol. Stateless means client request a resource a server respond to that request remembering the request later. So how website knows whether you are a unique user or you have visited previously. How they remember your previous browsing history, language preference etc.