I keep gettin header errors with using sessions! I want to check that when a user logs in and a seesion is created that when the users go to a page that can only be viewed by user the session is still there and that user is still valid.
the code to create the session in my login form is
Code: Select all
<?php$IP = $REMOTE_ADDR;
$Q02 = "SELECT *
FROM $dbtable
WHERE UserName='$UserName'";
$R02 = odbc_exec($db,$Q02) or die("Bad Q02:".mysql_error());
$Info = odbc_fetch_row($R02,1);
$SmartID = $Info['ID'];
$Q03 = "UPDATE $dbtable
SET IPAddress='$IP'
WHERE UserName='$UserName'";
$R03 = odbc_exec($db,$Q03) or die("Bad Q03:".mysql_error());
$Expire = 365*24*3600;
setcookie("UserName","$UserName",time()+$Expire,"/","");
setcookie("SmartID","$SmartID",time()+$Expire,"/","");
session_start();
session_register('UserName');
session_register('SmartID');
$_SESSION['UserName'] = $UserName;
$_SESSION['SmartID'] = $SmartID;
header("Location: DeftCallLog.php");
?>Code: Select all
<?php
<?PHP
include("functions.php");
global $SmartID;
if (!$HTTP_COOKIE_VARS['UserName'] || !$HTTP_COOKIE_VARS['SmartID'])
{
session_start();
if(!session_is_registered('UserName') || !session_is_registered('SmartID'))
{
$ErrorCode = "The Page You Requested Is For Members Only<BR><BR>Please Login Or <A HREF='register.php'><B>Register</B></A>";
ViewHeader($SmartID);
//ViewLoginForm($UserName, $ErrorCode);
ViewFooter();
exit;
}
}
$db = odbc_connect($dbsource, $dbuser, $dbpass) or die(odbc_errormsg);
$Q01 = "SELECT *
FROM $dbtable
WHERE ID='$SmartID'";
$R01 = odbc_exec($db,$Q01) or die("Bad Q01:".mysql_error());
ViewHeader($SmartID);
?>
?>Cannot send session cookie - headers already sent in F:\Support on line 6 PHP Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent in F:\Support on line 6
I dont understand it because i have no spaces etc!
Thanx for any help!