PHP cookies

Reply

Join Date: Dec 2006
Posts: 25
Reputation: wandie is an unknown quantity at this point 
Solved Threads: 0
wandie wandie is offline Offline
Light Poster

PHP cookies

 
0
  #1
Mar 17th, 2008
Can someone please help me I have made an example, of an cookies I have added a value 45 but i have created another page that displays. This prob is when i run the code that has the value 45 its suppose to give me a blank page byut i get this error on my browser

"Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\lesson\cookies\cookies.php:6) in C:\xampp\htdocs\lesson\cookies\cookies.php on line 11"

this is the code i put the cookie its suppose to just give a blank page but the value is stored in the cookie

  1. <?php
  2. setcookie('test',45, time()+(60*60*24+7));
  3. ?>
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: PHP cookies

 
0
  #2
Mar 17th, 2008
This is pretty common for programmers new to php. We'll need to see more code. Are you using echo or print before the header? Here's an article about the error.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 561
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: PHP cookies

 
0
  #3
Mar 17th, 2008
You must not echo anything before header location
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 68
Reputation: JRSofty is an unknown quantity at this point 
Solved Threads: 10
JRSofty's Avatar
JRSofty JRSofty is offline Offline
Junior Poster in Training

Re: PHP cookies

 
0
  #4
Mar 18th, 2008
Also any characters (even null or whitespace) before the opening <?php tag can also cause this error so make sure that your <?php starts at the very first line and column of your script.

In particular check line 6 (cookies.php:6) to see what you have that outputs there.
Last edited by JRSofty; Mar 18th, 2008 at 4:46 am. Reason: Adding some info
JRSofty Programming | .NET Dreaming | GalahTech

If your question is solved then mark the thread solved. If someone gives you good advice then give them some rep.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC