简单的在线检查器

时间:2015-10-18 18:56:28

标签: php session-variables

通过CMS I&#m; m building建立一个简单的工具,让我很容易判断用户是在线还是离线?现在我已经

class IUser {
    public function User($arg) {
        switch($arg) {
            case "online":
            self::CheckKey();
            break;
        }
    }
    public function CheckKey() {
        if(isset($_SESSION['key']['userid'])) {
            return true;
        }
        else {
            return false;
        }
    }
}

然后进行实际检查

$user = new IUser();
if($user->User("online") == true) {
    echo "user online";
}
else {
    echo "user offline";
}

因此理论上它应该在id键未设置时显示用户离线,而是始终返回false。如果有人看到我在这里做错了什么,我们将不胜感激。

2 个答案:

答案 0 :(得分:0)

您的User()函数必须返回一些内容......

float aveg(float a, float b){

答案 1 :(得分:0)

public static Google.Apis.YouTube.v3.YouTubeService AuthenticateOaut(string clientId, string clientSecret, string userName) { string[] scopes = new string[] { Google.Apis.YouTube.v3.YouTubeService.Scope.Youtube, // view and manage your YouTube account Google.Apis.YouTube.v3.YouTubeService.Scope.YoutubeForceSsl, Google.Apis.YouTube.v3.YouTubeService.Scope.Youtubepartner, Google.Apis.YouTube.v3.YouTubeService.Scope.YoutubepartnerChannelAudit, Google.Apis.YouTube.v3.YouTubeService.Scope.YoutubeReadonly, Google.Apis.YouTube.v3.YouTubeService.Scope.YoutubeUpload}; try { // here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData% UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret } , scopes , userName , CancellationToken.None , new FileDataStore("Daimto.YouTube.Auth.Store")).Result; Google.Apis.YouTube.v3.YouTubeService service = new Google.Apis.YouTube.v3.YouTubeService(new Google.Apis.YouTube.v3.YouTubeService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Web client 1", }); return service; } catch (Exception ex) { Console.WriteLine(ex.InnerException); return null; } } 函数不会返回任何内容。您需要额外的User来将检查结果传播给调用者:

return