Jump to content

UniqueHaze

New Members
  • Posts

    5
  • Joined

  • Last visited

UniqueHaze's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yeah I understand that, I'm just making a simple chat room thing. Wanted to get myself into PHP abit more so I just thought about a random project. I know PHP isnt really correct for it but its never going to be hosted more just for the learning side of it all, so the idea was when they haven't been active for the half hour the Cron runs and deletes the users from the table so if needed another user could use the same name
  2. I managed to get it working but working out the difference in the time then just see if its greater or not. $MaxTime = 1200; $Dif = $Time - $CheckOnline['lastaction']; // echo $Dif; if ($Dif > $MaxTime){ header("Location: Logout.php"); } An additional thing I'm trying is as soon as they "Logout" it deletes the record from the Database. Although if the user just closes the web browser it doesn't delete the entry so I thought about running a Cron Job every 5min / 10min or so which will check the last action time and if its not move in say 30min it automatically deletes that record. I've got the same code todo it but on the delete query I'm not sure what the Where lastaction = will be? So: $MaxTime = 60; // 1200 normal $Dif = $Time - $CheckOnline['lastaction']; // echo $Dif; if ($Dif > $MaxTime){ $sql4 = "DELETE * FROM UsersOnline WHERE lastaction => :last"; $stmt4 = $pdo->prepare($sql4); $stmt4->bindValue(':last', $CheckOnline['lastaction']); $stmt4->execute(); } My value for last isn't right at the moment but not sure how to define what rows to delete? Sorry if thats not to clear. Thanks
  3. I've just been playing around with it all, I've still got it as a string in the Database so been trying with strtotime() although its still just sending me to the logout page without logging me in
  4. Its a string, but now you've mentioned that i feel it should be a timestamp?
  5. Hello, I'm currently storing a timestamp of the users last activity in my database in which if that hasn't been updated for 15 minutes (for testing doing 2 minutes) I want it to log the user out. I have been trying different things but they all seem to log me out even though they shouldn't be. Example of something I've tried $Online = time() - 120; if ($CheckOnline['lastaction'] < $Online){ header("Location: Logout.php"); session_destroy(); } Am I going at this the wrong way.? If I do $Online < $CheckOnline['lastaction'] it keeps me logged in but never logs me out. Any help would be brillaint. Thank you!
×
×
  • 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.