How to add a cookie?

Answer Posted / rupali

bool setcookie ( string $name [, string $value [, int
$expire [, string $path [, string $domain [, bool $secure
[, bool $httponly ]]]]]] )
for e.g.
<?php
$value = 'something from somewhere';

setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600); /* expire in
1 hour */
setcookie("TestCookie", $value, time()
+3600, "/~rasmus/", ".example.com", 1);
?>

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why use static methods php?

544


Do you know what does mvc stand for and what does each component do?

505


Tell me how to strip whitespace (or other characters) from the beginning and end of a string?

536


How to find the position of the first occurrence of a substring in a string?

506


Tell me is it possible to protect special characters in a query string?

498






How to create a mysql connection in php?

524


How to retrieve values out of an array?

524


What is $_ files in php?

562


Does php need html?

535


How can we display the output directly to the browser?

529


Which is better php or nodejs?

518


What distinguishes php from something like client side java script?

533


In how many ways we can retrieve the data in the result set of mysql using php?

497


What is meant by public, private, protected, static and final scopes?

534


How to create an array in php?

557