Home >> PHP >> What Is a Cookie in PHP

What Is a Cookie in PHP

Cookie is a small file that stored on the client computer. A cookie is used to identify a user.

Syntax

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

Set Cookie

setcookie('user','ram',time()+60*60*24);

Access Cookie

echo $_COOKIE['user'];

Remove Cookie

setcookie('user','ram',time()-60*60*24);

Example

setcookie("user","ram",time()+60*60*24);// create cookie

echo $_COOKIE['user'];//access cookie

setcookie("user","ram",time()-60*60*24);//destroy cookie

Output

ram

 

Post Your Comment

Next Questions
What Is a Persistent Cookie
What does a special set of tags do
What are tags type
How do you define a constant
How To Write the FORM Tag for Uploading Files
What is the difference between include, include_once
What is the difference between require and require_once
What is difference between include_once and require_once
What is difference between include and require
What is meant by urlencode and urldecode
How To Get the Uploaded File Information
Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars
How do you pass a variable by value
How do I find out the number of parameters passed into function
How To Protect Special Characters in Query String
What is the difference between GET and POST
What are the different types of errors
If conditional statement
If else conditional statement
If else / else if conditional statement
Switch conditional statement
For loop
While loop
Do while loop
Foreach loop

Copyright ©2022 coderraj.com. All Rights Reserved.