ravravrav Posted November 26, 2006 Share Posted November 26, 2006 Hi I have this code which isn't fully complete but I'd like to change it in a function so I can call it whenever I need to check if a user is logged in or not:I'd like to put it into something called logincheck.php...[code]//Checks if there is a login cookieif(isset($_COOKIE['my_hash']))//if there is, it checks to see if my_hash = userhash{ $c_user = $_COOKIE['my_username']; $c_hash = $_COOKIE['my_hash']; $check = mysql_query("SELECT * FROM Users WHERE Username = '$c_user'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) {if ($c_hash != $info['Userhash']) // not logged in{ }else // logged in already{ header("Location: users.php");}}}[/code]Any ideas how I would change it and how to call it from other pages?Thx Quote Link to comment https://forums.phpfreaks.com/topic/28474-check-if-logged-in-function/ Share on other sites More sharing options...
fenway Posted November 26, 2006 Share Posted November 26, 2006 an include()? Quote Link to comment https://forums.phpfreaks.com/topic/28474-check-if-logged-in-function/#findComment-130323 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.