Hi,

I have this piece of code which authenticates the user then sets a cookie.
The problem is that I cannot read the cookie later, either with $cookiename
or $_COOKIE["cookiename"].

My code =


<?php
$colcode='red';
$c1=$uid;
setcookie ("uid", "$c1");
$db = 'herondiary';
$dbuser = 'root';
$dbpass = '';
$dbhost = 'localhost';
mysql_connect($dbhost,$dbuser,$dbpass) or die("could not connect");
mysql_select_db("$db") or die("could not open database");
if (!isset($uid) || !isset($pwd)){
        header("Location: default.php");
}else{
        $query = "select * ";
        $query.= "from users ";
        $query.= "where (id='".$uid."' ";
        $query.= "AND pwd='".$pwd."')";
        $result = mysql_query($query);
        $row = mysql_num_rows($result);
        if ($row == "0") {
        echo $query;
                header("Location: default.php");
        }else{
                while ($row = mysql_fetch_assoc($result)){
                        setcookie ("valid", "ok", time() +28800);
                }
        }
header("Location: diary.php");
}
?>

And before someone suggests sessions, I've loooked at several tutorials and
cannot get them to work either.

This is all set up using PHP4.0.6 on Win NT4.

Any help appeciated - this is doing my head in.

Cheers

George

===

George Pitcher
HERON Technical Manager
Ingenta plc
23-38 Hythe Bridge Street, Oxford, OX1 2ET
T  +44 (0)1865 799137 direct
T  +44 (0)1865 799000 switchboard
F  +44 (0)1865 799134
E  [EMAIL PROTECTED]

www.ingenta.com
Ingenta: Empowering the exchange of academic and professional content
online.


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to