Mark,
You might try using sessions instead of cookies. The following code
checks the session and credentials.
<?php
error_reporting(0);
session_start();
print("<HTML><HEAD><TITLE>Login Page One</TITLE></HEAD>\n<BODY>\n"); //
Start the session system
error_reporting(0);
session_start();
// if the login form was posted and the uid was set (and valid)
if($_POST['logon'] and $_POST['password'] and
!isset($_SESSION['logon'])){
// set our session vars.
$mysql_user = "root";
$mysql_password = "";
$link = mysql_connect("localhost", $mysql_user,
$mysql_password)
or die("Error, your username and/or password is
not correct");
$first = mysql_query("select * from time.main where logon_id =
'$logon'")
or die("Invalid query");
while ($row = mysql_fetch_array($first, MYSQL_NUM)) {
$pass = $row[7];
}
mysql_free_result($first);
if ($_POST['password'] == $pass)
{
$_SESSION['logon'] = $_POST['logon'];
$_SESSION['logged_in'] = true;
}
else
{
header("Location: sessionerror.php");
}
}
// if the logoff was clicked...
if($_GET['logoff']){
print("<p>Bye, Bye {$_SESSION['logon']}. Thanks for stopping
by!</p>");
session_unset(); // clean out the session
session_destroy(); // delete the record,file,etc
}
if($_SESSION['logged_in'])
{
print ("Page One");
print ("<br><a href='session2.php'>Go To Page Two</a><br>");
print("<a href='session.php?logoff=true'>[logoff]</a><br>");
} else {
header("Location: sessionstart.php");
}
print("</BODY></HTML>");
?>
You could try the following cookie code if sessions won't work.
<?php
$cookie_name = "cookiename";
if(empty($HTTP_COOKIE_VARS[$cookie_name])) {
$user_time=time();
$user_ip=$HTTP_SERVER_VARS["REMOTE_ADDR"];
$uid=$user_time.$user_ip;
$expiretime=time()+7600;
$c_name = $cookie_name; # cookie name
$c_data = "PHPSESSID".$uid.""; # cookie data
$c_path= "/"; # "/"= all directories or
"/php/"=named path
$c_domain = ""; # leaving empty covers all domains
$c_secure = 0; # secure server? 1=true,0=false
setCookie("$c_name","$c_data","$expiretime","$c_path","$c_domain","$c_se
cure");
?>
<html><head><title>php unique number cookie</title>
</head><body>
<h2>PHP UNIQUE NUMBERED COOKIE DATA</h2>
<?php
echo"<b>Cookie Name:</b> $c_name<br>";
echo"<b>Data: </b>$c_data<br>";
echo"<b>Unix Time:</b> $c_time<br>";
echo"<b>Converted time: </b><br>";
echo"<b>Path Accepted:</b> $c_path<br>";
echo"<b>Domain Accepted:</b> www.yourwebserver.com<br>";
echo"<b>Secure (Yes=1 No=0):</b> $c_secure<br>";
?>
<body></html>
-----Original Message-----
From: Mark Anderson [mailto:[EMAIL PROTECTED]
Sent: 03 July 2003 10:34 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] cookies problem
Hi everybody:
I have php 4.3.2 running as a isapi module on WinXP with IIS 5.1.
When I run the following script:
setcookie("auth_login",$cookie_val['auth_login'],time() + 3600); or
setcookie("auth_level",$cookie_val['auth_level'],time() + 3600);
it fails to set the cookie in browsers different of netscape
navigator. ie opera or internet explorer. nevertheless it works
localy with internet explorer. I have check all kind of privacy
settings in this browsers and it remains the same... does someone
have a clue about this?
Thanks in advance
Mark
Sent by Medscape Mail: Free Portable E-mail for Professionals on the
Move
http://www.medscape.com
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php