You are here: Re: Strange error while trying to set a cookie « PHP Programming Language « IT news, forums, messages
Re: Strange error while trying to set a cookie

Posted by Pedro Graca on 09/27/22 11:37

Fernando Rodríguez wrote:
> OK, here's the full code:
>
> -----------------------------------
> <html>
> <head>
> <title>Untitled Document</title>
> <?
> $cookieValue = 'abra cadabra, pedo de cabra';
> setcookie('aTestCookie', $cookieValue, time() + 3600);
> ?>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<snip>
> ------------------------------------
>
> This causes the follwoing output:
>
> Warning: Cannot modify header information - headers already sent by (output
> started at c:\proyectos\websites\test\index.php:4) in c:\proyectos\websites\test\index.php
> on line 6

try

-----------------------------------
1 <?php
2 $cookieValue = 'abra cadabra, pedo de cabra';
3 setcookie('aTestCookie', $cookieValue, time() + 3600);
4 ?>
5 <html>
....


I started the code with "<?php" because, instead of "<?", it will work
on all servers irrespective of their configuration. Your PHP start tag
needs a specific configuration (short_open_tags IIRC) to work.

--
If you're posting through Google read <http://cfaj.freeshell.org/google>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация