Jump to content
Sign in to follow this  
chaos421

Trouble with cookies and Safari

Recommended Posts

Hey all. First post here.

 

I'm having some difficulty with cookies and Safari. I've pasted my code below. isValidUser is a function that queries the database. When I test it out on Chrome it works well. In Safari I'm able to log in, but as soon as I navigate away from the page, the cookies disappear. I've tried several permutations with the URL at the end of setcookie including with or without leading '.' and with or without trailing '/' without success.

 

Any help would be greatly appreciated.

 

Thanks,

Keith

/*------------------------------------------------------------------- *  login *   *  username: is the person's e-mail address *  password: is stored separately *-------------------------------------------------------------------*/function login ($username, $password){	    if (!isValidUser($username, $password))        return false;	    setcookie('username', $username, time()+60*60*24*365, '/', '.northernlightsnordic.org');    setcookie('password', md5($password), time()+60*60*24*365, '/', '.northernlightsnordic.org');    return true;} //end login/*------------------------------------------------------------------- *  logout *   *  *-------------------------------------------------------------------*/function logout (){    setcookie('username', "", time() - 3600, '/', '.northernlightsnordic.org');    setcookie('password', "", time() - 3600, '/', '.northernlightsnordic.org');    return true;} //end logout

Share this post


Link to post
Share on other sites

I would advise against putting login details into a cookie. Why not use SESSION?

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...