Blog Details



* PHP Cookies :-

What is a Cookie?

A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.

How to Create a Cookie?

The setcookie() function is used to set a cookie.

Syntax :-

setcookie(name, value, expire, path, domain);

Example 1 :-

<?php setcookie("user", "Alex Porter", time()+3600); ?> <html> .....

Example 2 :-

<?php $expire=time()+60*60*24*30; setcookie("user", "Alex Porter", $expire); ?> <html> .....

How to Retrieve a Cookie Value?

<?php // Print a cookie echo $_COOKIE["user"]; // A way to view all cookies print_r($_COOKIE); ?>

How to Delete a Cookie?

<?php // set the expiration date to one hour ago setcookie("user", "", time()-3600); ?>



Latest posts

Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t


<ol> <li><a href="

Creating Model

<ol> <li><a href="

Get Free Quote