cookies - PHP setcookie won't work -


i baffled problem. setting cookie should easiest thing in world, whatever reason it's not working. i'm trying test-script work. looks this:

    $cookie_name = "user";     $cookie_value = "john doe";      setcookie($cookie_name, $cookie_value, time() + 86400 * 30, "/");     setcookie("act", "sj", time() + 86400 * 365);     setcookie("bbba", "hello", time() + 86400);      echo $_cookie['act'];     echo $_cookie['bbba'];     echo $_cookie['user']; 

none of these cookies set. nothing echo, , can not find cookies when using inspector. i've tried following: - placing echo $_cookie in file in same directory. - , without ob_start() , ob_flush() - using "/", "/direcotry" , nothing @ path - moving file root directory see if works there.

nothing seems work, , cannot see possibly wrong. other scripts using cookies working on same domain - located on web hotel.

can see problem here?

cookies not become visible until next loading of page cookie should visible for. test if cookie set, check cookie on next loading page before cookie expires. expire time set via expire parameter. nice way debug existence of cookies calling print_r($_cookie);.

it's php manual. can set value in $_cookie array manual if want in same page which's declared.

$_cookie['key'] = 'value'; echo $_cookie['key']; 

php manual setcookie


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -