How do I get cookies to work?

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
mickey
-


Joined: 09 Dec 2002
Posts: 25

PostPosted: Sun Feb 23, 2003 3:08 pm    Post subject: How do I get cookies to work? Reply with quote

I am having a problem getting cookies to work on my computer, I have:

1. made sure that the browser is set to accept them and
2. changed my php.ini file (to what has been suggested in some of the other postings), as below:

session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 1
session.cookie_lifetime = 0
session.cookie_path = c:\Program Files\Abyss Web Server\tmp
session.cookie_domain = localhost

is there something else that I may have missed? :?:

this is the script that i am using:
<?
$cookie_name = "test_cookie";
$cookie_value = "test_string";
$cookie_expire = time()+900;
$cookie_domain = "http://localhost";
setcookie($cookie_name, $cookie_value, $cookie_expire, "/", $cookie_domain, 0);
?>
<html>
<head><title>Set Test</title>
</head>
<body>

<h1>cookie sent!</h1>
</body>
</html>
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Feb 24, 2003 1:17 am    Post subject: Re: How do I get cookies to work? Reply with quote

Do not use http in $cookie_domain = "http://localhost";
Change it to $cookie_domain = "localhost";
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
mickey
-


Joined: 09 Dec 2002
Posts: 25

PostPosted: Mon Feb 24, 2003 4:02 am    Post subject: Reply with quote

Thanks for the help. I changed the part indicated to "localhost" but this hasn't made a difference, any other ideas please.
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Tue Feb 25, 2003 3:23 am    Post subject: Re: How do I get cookies to work? Reply with quote

Mickey, there are a lot of incompatibilities between browsers regarding cookies. We managed to have them work using your example on both IE and Opera by avoiding refering to the domain name.


Code:

<?
$cookie_name = "test_cookie";
$cookie_value = "test_string";
$cookie_expire = time()+900;
setcookie($cookie_name, $cookie_value, $cookie_expire, "/", "", 0);
?>
<html>
<head><title>Set Test</title>
</head>
<body>

<h1>cookie sent!</h1>
</body>
</html>


We recommend reading the discussion in the PHP reference about SetCookie for more information about browser-cookies issues.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
mickey
-


Joined: 09 Dec 2002
Posts: 25

PostPosted: Tue Feb 25, 2003 1:58 pm    Post subject: Reply with quote

Thankyou so much...made the changes and it works now. I had tried in three browsers IE, Opera, and Netscape and it wouldn't work in either.


will take a look at the PHP reference,

Thanks again :D
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group