Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to create cookie in php

// SYNTAX
//setcookie(name, value, expire, path, domain, secure, httponly);
$cookie_name = "LoginUser";
$cookie_value = "ex@gmail.com";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
if(!isset($_COOKIE[$cookie_name])) {
  echo "Cookie '" . $cookie_name . "' is not set!";
} else {
  echo "Cookie '" . $cookie_name . "' is set!<br>";
  echo "Value is: " . $_COOKIE[$cookie_name];
}
// FOR UNSET COOCKIE
 unset($_COOKIE['LoginUser']);
 
PREVIOUS NEXT
Tagged: #create #cookie #php
ADD COMMENT
Topic
Name
8+6 =