Jump to content

set cookie function for both www.domain.com and domain.com


Recommended Posts

I searched but couldn't find a clear answer so I'm sorry if this is a repeat.  If you point me in the right direction, I'll go :)

When I set a cookie, it only sets it on my domain without the www. (so if someone uses www.domain.com, the cookie doesn't work).

 

Here's what I have:

setcookie("matewan_login",$joined,time()+62899200);

 

Suggestions?

 

I appreciate everyone's time...

Just specify your domain with a dot in front (and if you want the cookie to work in all directories of you domain, use a slash as below):

 

<?php
setcookie('matewan_login', $joined, time()+62899200, '/', '.domain.com');
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.