setcookie

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
User avatar
jbdphp
Forum Newbie
Posts: 6
Joined: Mon Sep 02, 2002 4:53 pm

setcookie

Post by jbdphp »

Having trouble with the setcookie function this is what I get:

Warning: Cannot add header information - headers already sent by (output started at /home/ba/public_html/user/emailshow.php:13) in /home/ba/public_html/user/emailshow.php on line 74

Warning: Cannot add header information - headers already sent by (output started at /home/ba/public_html/user/emailshow.php:13) in /home/ba/public_html/user/emailshow.php on line 75

Code:

Code: Select all

<?php


                setcookie("yourname", "Justin", time() + (86400 * 30));
	setcookie("youremail", "hey@hey.net", time() + (86400 * 30));
				
// I even tried:
//@setcookie("yourname", "Justin", time() + (86400 * 30));
//still doesn't work!	

    echo "Thank you $yourname your message was sent!";
					

?>
Thanks in advance (note this code is from part of bigger script)
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

well, obviously, headers are being sent...

check for a space before the "<?" and make sure no html is being outputted
Agent Dwarf
Forum Newbie
Posts: 9
Joined: Sat Sep 21, 2002 2:03 pm

Post by Agent Dwarf »

Yeah, it seems as though headers are sent, and you're not showing us the full code.

Tip: If you want to check if headers are sent during your code, use headers_sent().
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

http://www.devnetwork.net/forums/viewtopic.php?t=1157

And also what on the line 13 of your code?
Post Reply