Zepo. Posted December 24, 2007 Share Posted December 24, 2007 function login($mes){ global $config; if (isset($_COOKIE["user"])){ $out[body].="<br /> <center> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Login</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='center' align='left'><center> <b>You are already logged in!</center></td></tr> </table> </center><br /><br /><br /><br />"; }else{ $out[body].=" <br /> <center> <table width='400' border='0' cellspacing='1' bgcolor='#000000' cellpadding='1'> <form method='post'> <tr bgcolor='$config[altcolor]'> <td background='$config[bg]' width='100%' valign='center' align='left' colspan='2'> <strong>Login</strong>"; if(isset($mes)){ $out[body].="<font color='red'>(Incorrect Login)</red>"; } $out[body].=" </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Username</td> <td width='60%' valign='center' align='center'><input type='text' name='login[name]' class='input' value='$login[name]' size='32' maxlength='15'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Password</td> <td width='60%' valign='center' align='center'><input type='password' class='input' name='login[pass]' value='' size='32' maxlength='15'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Login Length</td> <td width='60%' valign='center' align='center'> <select class='button' name='login[clength]'> <option value='60'>1 Hour</option> <option value='1440'>1 Day</option> <option value='10080'>1 Week</option> <option value='43200'>1 Month</option> <option value='-1' selected='selected'>Forever</option> </select></td> </tr> <tr bgcolor='$config[altcolorb]'> <td><a href='./register.php'>Register Now!</a></td> <td width='100%' valign='top' align='right'> <input type='hidden' name='act' value='setlogin'> <input type='submit' class='button' name='submit' value='Login >>'></td> </form> </tr> </table> <br /><br /> <table width='400' border='0' cellspacing='1' cellpadding='2' bgcolor='#000000'> <form method='post' action='./forgotpw.php'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Forgot Password?</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Username</td> <td width='60%' valign='center' align='center'><input type='text' name='login[name]' class='input' value='' size='25' maxlength='10'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'><img src='./includes/captcha.php' /></td> <td width='60%' valign='center' align='center'>Enter the text you see in the image.<br /> <input class='input' type='text' name='login[capt]' value='' size='40' maxlength='13'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='top' align='right' colspan='2'> <input type='submit' class='button' name='submit' value='Resend >>'></td> </form> </tr> </table> </center><br /><br />"; } include("$config[html]"); } function set($login){ global $config; if(!mysql_num_rows(mysql_query("SELECT id FROM members WHERE name='$login[name]' AND password='$login[pass]'"))){ $mes="1"; login($mes); exit; } $getid=mysql_query("SELECT id,act FROM members WHERE name='$login[name]'"); $getid=mysql_fetch_array($getid); if($getid[act] == 0){ error("Your account is not activated yet, you must click the link provided in your welcome email."); } //Set Cookies setcookie(tid,$getid[id],$login[clength]); setcookie(user,$login[name],$login[clength]); setcookie(pass,$login[pass],$login[clength]); } Full code, the login lengths arn't working.... Quote Link to comment https://forums.phpfreaks.com/topic/83068-cookie-question-again/ Share on other sites More sharing options...
revraz Posted December 24, 2007 Share Posted December 24, 2007 Because you are not using setcookie right, as I explained in your other post Quote Link to comment https://forums.phpfreaks.com/topic/83068-cookie-question-again/#findComment-422574 Share on other sites More sharing options...
Zepo. Posted December 24, 2007 Author Share Posted December 24, 2007 Yes that didnt work though. Quote Link to comment https://forums.phpfreaks.com/topic/83068-cookie-question-again/#findComment-422583 Share on other sites More sharing options...
corbin Posted December 24, 2007 Share Posted December 24, 2007 setcookie(tid,$getid[id],$login[clength]); setcookie(user,$login[name],$login[clength]); setcookie(pass,$login[pass],$login[clength]); Try print_r($login) right above that, and see if it says clength is set. It's also worth noting, it's a bad practice to not use quotes there, since PHP treats plain text as constants. If a constant for that plain text isn't set, then it will treat it like it was wrapped in quotes, but I've seen a few problems caused by that before. Quote Link to comment https://forums.phpfreaks.com/topic/83068-cookie-question-again/#findComment-422588 Share on other sites More sharing options...
Zepo. Posted December 24, 2007 Author Share Posted December 24, 2007 Clength is set, i guess ill quote it then. Quote Link to comment https://forums.phpfreaks.com/topic/83068-cookie-question-again/#findComment-422590 Share on other sites More sharing options...
PFMaBiSmAd Posted December 24, 2007 Share Posted December 24, 2007 I think if you would read the definition of the expire parameter, it would help - http://php.net/setcookie The current time on the server + the amount you add to the current time is what the examples in the manual and the later code in your other thread on this problem is sending to the browser in the cookie. However, the current time in the browser is what determines when the cookie is deleted. If the browser is in a later time zone than the server, the expire time that you are using in the cookie could already be past and the cookie would be deleted as soon as the browser closes. Quote Link to comment https://forums.phpfreaks.com/topic/83068-cookie-question-again/#findComment-422651 Share on other sites More sharing options...
Zepo. Posted December 25, 2007 Author Share Posted December 25, 2007 So is this one possible? setcookie("tid",$getid[id], time()+60 * $login[clength]); setcookie("user",$login[name], time()+60 * $login[clength]); setcookie("pass",$login[pass], time()+60 * $login[clength]); Quote Link to comment https://forums.phpfreaks.com/topic/83068-cookie-question-again/#findComment-422761 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.