E
E
ex3xeng2015-11-23 09:10:38
PHP
ex3xeng, 2015-11-23 09:10:38

How to create a cookie correctly?

I'm trying to create a cookie like this:
$domain = str_replace('www.', '', $_SERVER['HTTP_HOST']); //localhost
setcookie ('cookie', 'value', time()+(60*60*24*30), '/', $domain, true, true);
but I can’t understand, then it was created like, now it has ceased to be created.
I try to create setcookie ('cookie', 'value', time()+(60*60*24*30), '/');
what about $domain, true, true?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2015-11-23
@Stalker_RED

Read the documentation , please.
$domain, true, true - optional parameters. In general , all parameters are optional, except for the first one.
How do you check if a cookie has been created? Have you tried looking in devtools or firebug? (F12)
FP0mktN.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question