How to set php setcookie
Syntax php setcookie:
setcookie(username,$_POST['username'],time()+60*60*24*365,'/account','www.example.com');
setcookie(password,$_POST['password'],time()+60*60*24*365,'/account','www.example.com');
Syntax. setcookie(name, value, expire, path, domain, secure, httponly);
- In the above example we set two cookies for 'Username' and 'Password'with values $_POST['username'] and $_POST['password'].
- And assign a time of one year because 60*60*24*365=1 year.
- These 3 parameter are very important for setting cookie
- Now the username and password for www.example.com has been saved for one year .You don't need to enter username and password again & again.