J
J
JackShcherbakov2018-02-04 19:13:12
PHP
JackShcherbakov, 2018-02-04 19:13:12

Why can't I set the php cookie?

Hello! On the server, there is such a hierarchy of cactologists:

site-|
       |
       |-newFolder-|
       |           |-cookie2.php
       |-cookie1.php

For some reason, I can't set the cookie from cookie2.php, while everything works from cookie1.php.
Here is the cooke1.php code:
<?php
setcookie("userid", "ralph", time()+3600);
print $_COOKIE["userid"];
?>

Ruzulat:
ralph
Everything works, I go to the browser and delete the cookie.
Now I'm trying to do the same, but from the cookie2.php file. I copy the code and as a result nothing is displayed.
What to do? What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
grisha2217, 2018-02-04
@grisha2217

You need to specify a domain for cookies, read the setcookie documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question