What's wrong with this code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SashaSlutsker
Forum Newbie
Posts: 18
Joined: Sat Mar 20, 2004 11:24 am

What's wrong with this code?

Post by SashaSlutsker »

I have been using sessions since I started programming in PHP, but now I need to use cookies. Anyway, this code is returning true. However, the cookie is not getting stored on the computer.

Code: Select all

if (!setcookie ("stay",crypt($_POST['password']),time() + 60*60*24*30*2, '.solarconflict.com', 0))
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

try

Code: Select all

<?php
if(!isset($_COOKIE['cookiename']))
{
setcookie('cookiename', 'value', time() + (60*60*24*30*2));
}
?>
SashaSlutsker
Forum Newbie
Posts: 18
Joined: Sat Mar 20, 2004 11:24 am

Post by SashaSlutsker »

Well, that's pretty much what I did. The only difference is that you checked if it was set, (I did that, but didn't post it) left out the last two parameters, and put parentheses around the numbers. Well, I tried doing that to my variables and it still did not work.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Is your browser set to enabled cookies?
SashaSlutsker
Forum Newbie
Posts: 18
Joined: Sat Mar 20, 2004 11:24 am

Post by SashaSlutsker »

Yes, it is.

*EDIT*

I got it to work. It was having problems with the domain part.
Post Reply