Problem with cookies in php

0

I'm trying to generate a system that records the person's email in a cookie so that he can add a list of properties of a site in the database and when he loads the site through his email pulls the list of favorite properties. p>

I made a simple form that plays to a page the post of his email. my cod that receives this as follows.

if(!empty($_POST['Fmail'])){
   setcookie( "meuemail", $_POST['Fmail'], strtotime( '+1 year' ) );
}

After that it refreshes the page

on the property page I have a simple script to validate this cookie

echo $_COOKIE['meuemail'];

But it always goes blank this is never filled. Where am I going wrong?

    
asked by anonymous 24.04.2017 / 23:53

1 answer

1
  

'/' means cookie is available throughout the site

if(!empty($_POST['Fmail'])){
  setcookie( "meuemail", $_POST['Fmail'], strtotime( '+1 year' ), '/' );
}
    
25.04.2017 / 00:39