Posted by Chris Hope on 01/07/05 07:46
Ben wrote:
> In my .php file, I'm using both session_start() and setcookie() before
> <html> tag. It gives me following warning message:
>
> Warning: Cannot modify header information - headers already sent by
> (output started at D:\Apache Group\Apache2\htdocs\YC\songs.php:4) in
> D:\Apache Group\Apache2\htdocs\YC\ycphpfunc.php on line 148
>
> My .php file looks like this:
>
> <?php session_start(); ?>
>
It looks to me like there's white space (a line break) right here
inbetween the closing ?> and opening <?php I'm not sure why you've
coded it like this though. Why not just have one code block? See my
example below.
> <?php
> ob_start();
> include 'ycphpfunc.php';
> $login = new login_class;
> if ($_POST[logusername] == "" || $_POST[logpassword] == "") {}
> else {
> $login->check_login($_POST['logusername'], $_POST['logpassword'],
> $_POST['remember']);
> }
> ob_end_flush();
> ?>
> <html>
> .......
> .......
> </html>
>
> The call to check_login()calls setcookie() function through another
> function inside my "ycphpfunc.php" file.
>
> Can someone show me a way to include both session_start() and
> setcookie() before <html>?
Change it to be like this:
<?php
session_start();
ob_start();
...
or like this:
<?php
ob_start();
session_start();
...
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Navigation:
[Reply to this message]
|