Reputation: 9521
I know we can create cookies on server side and on client side with javascript but I may lack some expertise.
My problem : I'm trying to pinpoint the creation of a cookie
My situation : I have disabled javascript in my browser and I cleaned all my cookies from this particular website. I did not reload the page. I track the network and when I click on a link, I can see a cookie in the first request. How is it possible?
there is a caption of the very first get request
Upvotes: 7
Views: 6414
Reputation: 784
Although it's been some time since you asked this question I'm still going to post this as a reference for anyone in the future.
It is also possible to create cookies with raw html by using the <meta>
tags:
<meta http-equiv="set-cookie" content="myCookie=cookie%20content">
check this article for more examples.
UPDATE
This feature has been deprecated and browsers are moving away from this method and going towards HTTP headers and the document.cookie
as noted by this answer
Upvotes: 4
Reputation: 241
You can use PHP
(PHP 4, PHP 5, PHP 7) you can use a function called "setcookie"
Syntax: setcookie(name, value, expire, path, domain, secure, httponly);
Just an example
<?php
$cookie_name = "user";
$cookie_value = "John Doe";
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];
}
?>
</body>
</html>
For more info click here!
Upvotes: 0