note 71743 deleted from function.setcookie by cmb

From: Date: Sun, 03 Mar 2019 11:29:22 +0000
Subject: note 71743 deleted from function.setcookie by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210299@lists.php.net to get a copy of this message
Note Submitter: kurtubba at gmail dot com ---- When setting a top level domain ex ".mydomain.com" you must add the secure arg so it should look like <?php setcookie("TestCookie", $value, time()+3600, "/", ".example.com", 0); ?> ignoring the secure arg makes IE ignores the cookie to get the top level domain use <?php $myDomain = ereg_replace('^[^\.]*\.([^\.]*)\.(.*)$', '\1.\2',$_SERVER['HTTP_HOST']); ?> to avoid localhost switch use <?php $phpCkDmn = $_SERVER['HTTP_HOST'] != "localhost" ? $myDomain : false; ?>

« previous php.notes (#210299) next »