PHP setcookie Function

PHP Cookies In Hindi – Cookies In Hindi

PHP

PHP Cookies In Hindi – Cookies In Hindi:- Cookies Ko Ham Isliye Istemal Karte Hai Ki Cookies User Ki Identify Ko Batati Hain |

Yadi Aapne  HTML Full Course  And CSS Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

PHP Cookies In Hindi

Cookie Ek Small File Hoti Hai Jo Ki Client Computer Par Store Hoti Hai And Cookie Webserver Ke Help Se Client Computer Par Store Ek Small File Hoti Hai |

Create Cookies In PHP In Hindi

Cookie Ko Create Karne Ke Liye setcookie() Functions Ka Istemal Kiya Jata Hain |

Syntax:

setcookie(name, value, expire_time, path, domain, secure, httponly);
  • name – Yaha Par Cookie Ka Name Define Karte Hain |
  • value – Yaha Par Cookie Ki Value Define Karte Hain |
  • expire_time – Yaha Par Cookie Ki Expire _time Define Karte Hain |

Example:

<?php
$cookie_name = "Danish";
$cookie_value = "MasterPrograming";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
?>

Jab Ham Cookie Ko Create Karte Hai To Uske Bad Ham expire_time define karte Hai Yani Ki Agar Hame Time 30 days Ka Rakhna Hoto Uske Liye Ham (86400 * 30) Value Denge | Iska Matlab Ye Hai Ki Cookie Available Rahegi us website Ke Under 30 Days Ke Liye And Uske Bad Cookie Expire Ho Jayegi |

PHP Create/Retrieve a Cookie in Hindi

Jab Ham Cookie Ko retrieve Karte Hai To Uske Liye Ham SuperGlobal Variable $_COOKIE Ka Istemal karna Padta Hai And Uske Sath Hi Cookie Ko Set Karne Ke Liye isset Function Ka Istemal Karne Padta Hain |

Example:

<?php
  $cookie_name = "Danish";
  $cookie_value = "MasterPrograming";

setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
?>
<html>
<body>

<?php
if(!isset($_COOKIE[$cookie_name])) {
  echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
  echo "Cookie '" . $cookie_name . "' is set!<br>";
  echo "Value is: " . $_COOKIE[$cookie_name];
}
?>

<p><strong>Note:</strong> Page Ko Reload Karke Aap Cookie Set Kar Sakte Hain ... Reload Your Page.</p>
</body>
</html>

Dhiyan Rahe Ki setcookie function ko Aap <html> Se Pahle Hi Istemal Kare

Output:

Cookie 'Danish' is set!
Value is: MasterPrograming
Note: Page Ko Reload Karke Aap Cookie Set Kar Sakte Hain ... Reload Your Page.

Delete a Cookie In PHP In Hindi

Cookie Ko Delete Karne Ke Past Ke Time Set Karna Hai Keval |

Example:

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

<?php
echo "Cookie 'user' is deleted.";
?>

</body>
</html>

Output:

Cookie 'user' is deleted

Leave a Reply

Your email address will not be published. Required fields are marked *