I am having a problem with setting cookie with php. I am trying to set a cookie (id) from www.example.com/login.php and I want to use from every place on the website. for example I want to use it in:
www.example.com/main.php
www.example.com/users.php
www.example.com/login.php
this is my php code
$expire = time() + 31556926;
$cookie_id = $insert_userid;
setcookie ("id");
setcookie("id", $cookie_id, $expire, '/', 'www.example.com');
i do not have any subdomain. Also For the domain index in the setcookie function I am not sure which on to provide. www.example.com or example.com
If you had subdomains and wanted to allow them:
Wikipedia is pretty useful on this: