Announcement

Collapse
No announcement yet.

Pattern to setcookie for domain and subdomains - how to

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pattern to setcookie for domain and subdomains - how to

    This is a really strong, effective pattern to set/remove cookie, suitable to set cookie for domain and subdomains.
    Code:
        $cookie_domain = preg_replace('/^[^\.]*\.([^\.]*)\.(.*)$/', '\1.\2',$_SERVER['HTTP_HOST']);
     // $cookie_domain = '.' . $cookie_domain; // this could be useful for hold browsers i've been noticed
     // exclude localhost from the joke
      $cookie_domain = $_SERVER['HTTP_HOST'] != "localhost" ? $cookie_domain : false;
    so,set or remove cookies: $cookie_domain var will contain the correct value for setcookie() domain field!
Previously entered content was automatically saved. Restore or Discard.
Auto-Saved
x
Insert: Thumbnail Small Medium Large Fullsize Remove  
x
x
Working...
X