Re: Warning: session_start()
| From: | Nazish | Date: | Thu, 19 May 2011 16:18:08 +0000 |
| Subject: | Re: Warning: session_start() | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-312917@lists.php.net to get a copy of this message | ||
I see.
So I moved session_start() to the beginning of the html script, and included
an output buffer. It looks like this:
<?php
ob_start(ob_gzhandler); //starts output buffer, compresses HTML
session_start();
?>
<html>
<head>
. . .
Then, in login_form.php (which is included on this index page), I deleted
session_start() since it is initiated at the start of the html script (and
produced error messages when it was in the middle of the conditional
statement):
if($login && $password)
{
if (mysql_num_rows($check_login))
{
// session_start();
$_SESSION ['login'] = $data['login'];
echo '<script
language="javascript">location.href="first_page.php"</script>';
exit;
}
It seems to work: the page redirects upon logging in, there's no error
message, the session seems to be remembered.
Thanks so much for the coding tips. They were extremely useful!!