I have a login page that is supposed to redirect the user to his private
page after login. But header("Locatio n: $url") does not work after I set
the $_SESSION variable - I get "Warning: Cannot modify header information -
headers already sent by ...
The abbreviated code on the login page looks like this:
<?php
session_start() ;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
[etc, etc]
[login form]
<?
if (credentials are valid)
{
session_start() ;
$_SESSION['username'] = $uid;
header("Locatio n: $url");
}
?>
One option I've heard about is using ob_start() at the top of the page - but
that seems to screw up my session. I could also use Javascript like this:
<script language="javas cript">
window.location .href=("<?php echo $url; ?>");
</script>
but then folks without Javascript won't get redirected.
Are there any other alternatives?
Thanks in advance.