Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-06-2008, 11:04 AM   #1
LQ Newbie
Registered: Feb 2008
Posts: 7

Rep: Reputation: 0
setcookie failed using host:: 'localhost'


I cannot get setcookie to work when using this code in php:

setcookie("auth", "1", 0, "/", "localhost", 0);

when I replace localhost with an empty string like this:

setcookie("auth", "1", 0, "/", "", 0);

everything works fine.

What is the cause this?
Old 04-06-2008, 03:40 PM   #2
Registered: Apr 2008
Posts: 100

Rep: Reputation: 15

Localhost is a reference for a computer system to it's own webserver. Why would you need cookies for that?

For a public webserver use your fully qualified domain name. Having the '.' (dot) before the domain name seems to help with certain browsers.

Maybe you should try ".localhost" or ".localhost.localdomain" if it's only for local testing.

Leaving the domain field empty obviously works - making the cookie available to the entire Internet, I guess.


Linux Archive

Last edited by marquardl; 05-01-2008 at 02:39 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't connect to host localhost Scoobsky Linux - Networking 3 10-26-2005 12:47 PM
Resolving <www.some remote host>.... failed: Host not found. koodoo Linux - Newbie 2 06-27-2005 09:48 AM
localhost error /etc/host.conf Burian Fedora 2 02-21-2005 07:03 PM
Kmail - Could not connect to host localhost mike8994 Linux - Newbie 0 10-14-2004 08:56 PM
Konkueror - Could not connect to host localhost coffen Linux - Networking 0 01-20-2002 12:15 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration