Jump to content

danieljgraham

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

danieljgraham's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Another useful function is if(empty($login_Username) || empty($login_Password)) { throw new Exception("Error, Please enter your Username and Password!"); }
  2. Hi There, I just wanted to share a really cool way of managing check boxes. For instance you could use them for user access functions etc For you to read the values in PHP, this returns a true or false (1 or 0) public function checkAccess($required) { // The value of the box your after....e.g......64 $m_access = $_SESSION['login_Access']; // This is where you store the checkbox value if ($required == 1 ) { if($m_access & $required) { return true; } } else { if(($m_access & $required) / $required == 1) { return true; } } return false; } or if((1024 & 64) / 64 == 1) { return true; } This function will always return a unique value as per the box checked. Hope people find it useful. Daniel [attachment deleted by admin]
  3. Thank you for your help, heres what i came up with, and appears to be really secure. if($login_Remember) { /* Check if Remember Me was set */ $sql = "UPDATE Users SET Session = '$session_id' WHERE id = " . $row['ID']; mysql_query($sql); setcookie('PDMS_SESSION', $session_id, time()+3600 * 24 * 30); } Then on every page i do a Session check, if that ok then it just returns true. Otherwise it'll check the cookie and and do an SQL query for that cookie Public function doLoginCheck () { if(isset($_SESSION['login_ID'])) { return true; } if(isset($_COOKIE['PDMS_SESSION'])) { $query = sprintf("SELECT users.* , user_groups.Value FROM users LEFT JOIN user_groups ON (users.Access = user_groups.ID) WHERE users.Session = '%s' LIMIT 0,1", $_COOKIE['PDMS_SESSION']); $result = mysql_query($query) or die('Error, Cookie check failed'); $row = mysql_fetch_array($result, MYSQL_ASSOC); $_SESSION['login_ID'] = $row['ID']; $_SESSION['login_Name'] = $row['Name']; $_SESSION['login_Access'] = $row['Value']; return true; } header("Location: login.php"); } Seems to do the trick. Thanks for your help. Dan
  4. Im trying to use the following code; if($login_Remember) { /* Check if Remember Me was set */ setcookie('login_ID', $row['ID'], time()+3600 * 24 * 30); setcookie('login_Name', $row['Name'], time()+3600 * 24 * 30); setcookie('login_Access', $row['Value'], time()+3600 * 24 * 30); } header("Location: index.php"); When i try to use it, the only cookie thats registered is the bottom on "login_Access". None of the others are. I have tried everything but nothings working. I dont get any error messages. Using PHP v5.3.3 on IIS Please help. Thanks [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.