Daney11 Posted March 14, 2008 Share Posted March 14, 2008 <?php include_once('settings.php'); // This Includes The Settings Of The Website include_once('functions.php'); // This Includes The Functions Of The Website include_once('team.php'); // This Includes The Team Information Of The Website if (isset($_POST['submitted'])) { $errors = array(); if (empty($_POST['member_email'])) { $errors[] = 'You Forgot To Enter Your Email Address'; } else { $member_email = escape_data($_POST['member_email']); } if (empty($_POST['member_password'])) { $errors[] = 'You Forgot To Enter Your Password'; } else { $member_password = escape_data($_POST['member_password']); } if (empty($errors)) { $query = 'SELECT * FROM members '."where member_email='$member_email'" . "and member_password='$member_password'" . "and member_teamid='$team_url'" . "and member_active='Yes'"; $result = mysql_query($query) or die(mysql_error()); $loginrow = mysql_fetch_array($result); if (mysql_num_rows($result) >0 ) { setcookie ('member_id', $loginrow['member_id'], time()+3600); setcookie ('member_teamid', $loginrow['member_teamid'], time()+3600); setcookie ('member_username', $loginrow['member_username'], time()+3600); setcookie ('member_nation', $loginrow['member_nation'], time()+3600); setcookie ('valid_user', $loginrow['member_email'], time()+3600); } else { } } else { $errors[] = 'Both dnt match'; } } else { $errors[] = NULL; } if (!empty($errors)) { foreach ($errors as $msg) { echo $msg; } } if (isset($_COOKIE['valid_user'])) { echo "lal"; } else { echo "LOL"; } ?> <form method="post" action="logina.php"> <table width="100%" cellpadding="0" cellspacing="0" border="0" height="60"> <tr> <td width="50%" height="20" valign="middle"> <strong>Username:</strong></td> <td width="50%" height="20" valign="middle"><input class="loginform" type="text" name="member_email"></td> </tr> <tr> <td width="50%" height="20" valign="middle"> <strong>Password:</strong></td> <td width="50%" height="20" valign="middle"><input class="loginform" type="password" name="member_password"></td> </tr> <tr> <td width="50%" height="20" valign="middle"> <strong><a href="forgot_password.php">Forgot Password?</a></strong></td> <td width="50%" height="20" valign="middle"><input class="loginform" type="submit" value="Login"><input type="hidden" name="submitted" value="true"></td> </tr> </table> </form> hey guys, im using the above login code but the cookies are not setting. Quote Link to comment Share on other sites More sharing options...
Demonic Posted March 14, 2008 Share Posted March 14, 2008 Try adding "ob_start()" at the top of your code and make sure cookies are enabled in your browser. Quote Link to comment Share on other sites More sharing options...
Daney11 Posted March 14, 2008 Author Share Posted March 14, 2008 Didnt work. Cookies are enabled. Quote Link to comment Share on other sites More sharing options...
accident Posted March 14, 2008 Share Posted March 14, 2008 need session_start(); Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 14, 2008 Share Posted March 14, 2008 not for cookies you don't. Quote Link to comment Share on other sites More sharing options...
Daney11 Posted March 14, 2008 Author Share Posted March 14, 2008 Hmm, i dont think you need session_start(); for cookies, only for session use.? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 14, 2008 Share Posted March 14, 2008 correct. Quote Link to comment Share on other sites More sharing options...
accident Posted March 14, 2008 Share Posted March 14, 2008 ah ok ... not sure why I thought you did. sorry Quote Link to comment Share on other sites More sharing options...
Daney11 Posted March 14, 2008 Author Share Posted March 14, 2008 So back to the point of the topic. Anyone know why the cookies are not setting? Quote Link to comment Share on other sites More sharing options...
thebadbad Posted March 14, 2008 Share Posted March 14, 2008 Be sure to run setcookie() before any output, since cookies are sent along the HTTP headers. Quote Link to comment Share on other sites More sharing options...
Daney11 Posted March 14, 2008 Author Share Posted March 14, 2008 I did, I ran the script i posted by itself. So nothing was outputting before? Quote Link to comment Share on other sites More sharing options...
Demonic Posted March 14, 2008 Share Posted March 14, 2008 (lol @ the dude who said you need session_start()) What browser are you using? Quote Link to comment Share on other sites More sharing options...
thebadbad Posted March 14, 2008 Share Posted March 14, 2008 What about in the included files? When I set cookies I also specify the path and domain arguments, but I'm not sure if that'll solve it. You could try? <?php setcookie('name', "$value", $timestamp, '/', '127.0.0.1'); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.