Need Help with Cookies in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
optimumdiscounts
Forum Newbie
Posts: 1
Joined: Fri Jun 13, 2003 5:55 am
Location: Illinois

Need Help with Cookies in PHP

Post by optimumdiscounts »

I need help with the following code.

Code that is executed if the user logs in with correct username & password (validate.php):

----------

$_SESSION['letmein'] = true;
$result = mysql_query("SELECT id, username AS uuname FROM user where username='$uname'",$connection);
if ($myrow = mysql_fetch_array($result)) {

$_SESSION["id"]=$myrow['id'];
$_SESSION["username"]=$myrow['uuname'];

header("Location: start.php?option=main");


---------

Code that is executed at top of surf.php:

<?
session_start();
require 'include.inc';
if (!isset($_SESSION['letmein'])){
header ("Location: index.php?invalid=PLEASE LOGIN");
}
----

I need a cookie placed that will automatically log a user in when they visit their surf.php link, the links look like this:

http://www.ANYSITE.com/surf.php?userid=384&username=od

Any help? Thanks in advance!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Post Reply