cris11368 Posted August 19, 2009 Share Posted August 19, 2009 Ok I literally started coding php like a few hours ago and I'm trying to get this to work <?php setcookie("status", 1, time()+120); $status = $_COOKIE['status']; if(($login = fsockopen("127.0.0.1", 7575)) == 1){$login = "Online";} else {$login = "Offline";} if(($world = fsockopen("127.0.0.1", 8484)) == 1){$world = "Online";} else {$world = "Offline";} echo $world.$login; ?> What it's supposed to do is check to see if the server is on, on the ports specified. If it's not just display OfflineOffline if they are then OnlineOnline. I was trying to use a cookie so that if it's been less than 120 seconds since the person last check the status that it would just use the OnlineOnline. Thought I could use that so this doesnt get spammed but I cant make that work. Link to comment https://forums.phpfreaks.com/topic/170939-problem-getting-this-code-working/ Share on other sites More sharing options...
Garethp Posted August 19, 2009 Share Posted August 19, 2009 <?php session_start(); if(!isset($_SESSION['time'])) { //It hasn't been used yet. $_SESSION['time'] = time()-120; } if($_SESSION['time'] < (time()-120)) { //It has been two mins } else { //Not been two mins } ?> Link to comment https://forums.phpfreaks.com/topic/170939-problem-getting-this-code-working/#findComment-901602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.