Re: Cookie Problems (Different than the post by David Jackson)

From: Date: Tue, 02 Mar 2004 18:23:31 +0000
Subject: Re: Cookie Problems (Different than the post by David Jackson)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-179285@lists.php.net to get a copy of this message
I bet you have some session management functions in include('lib/sessionfunc.php'); something like session_start() that also sends out header informations, but you can't send any headers AFTER you have started the output for eg: <? .... some cookies/session/header code1 ?> Some HTML output like: <html> <head> <? .... some cookies/session/header code2 ?> code1 will work ok, but code2 will fail with headers already sent error. Instead you should write : <? ALL cookies/session/header code ?> The HTML code <? other PHP code ?> the headers are sent before any HTML code, so if you have even one blank space sent to the output you can't modify the headers any more. "Brian J. Celenza" <bcelenza@fuse.net> wrote in message news:20040302174546.32440.qmail@pb1.pair.com... > Here's a snippet of the code. I'm sending the setcookie header out long > before any of the other headers, but I'm still getting: > Warning: Cannot modify header information - headers already sent by (output > started at C:\wwwroot\index.php:4) in C:\wwwroot\index.php on line 7 > > -----Code------ > > <? > function cookie_set($userid){ > if (isset($userid)){ > setcookie("vfsnet", $userid, time()+600); > } > } > cookie_set($_GET['user']); > ?> > <html> > <head> > <? > > include('lib/sessionfunc.php'); > include('lib/dbconnect.php'); > include('lib/filefunc.php'); > include('lib/urlfunc.php'); > ?> > <link rel="stylesheet" type="text/css" > href="themes/master.css"> > <title>Website0001</title> > <meta http-equiv="Content-Type" content="text/html; > charset=iso-8859-1"> > </head> > > ---Code--- > > Any ideas? > > Thanks > Brian > > > >

« previous php.general (#179285) next »