Ejemplo n.º 1
0
 public static function TryStartSession($username, $password)
 {
     if (!($habbo = Habbo::GetHabboByName($username))) {
         return "Error #1";
         //User not exists
     }
     if (!Habbo::CheckAuth($habbo, $password)) {
         return "Error #2";
         //Wrong Pass
     }
     CookieManager::SetCookie(CMS_COOKIE_LOGIN_NAME, json_encode(["username" => $username, "password" => $password]), 'json', time() + CMS_COOKIE_LOGIN_DURATION, Loc::GetHTTPHost(), Loc::GetMyIP());
 }
Ejemplo n.º 2
0
            self::SetCookie($name, $value, $type, $expire, $domain, $remote_addr);
        }
    }
    public static function RemoveCookie($cookie)
    {
        DB::RunFastQuery("DELETE FROM cms_cookies WHERE name = '{$cookie->name}' AND http_host = '{$cookie->http_host}' AND remote_addr = '{$cookie->remote_addr}'");
    }
    public static function ValidateCookie($cookie)
    {
        if ($cookie->expire <= time()) {
            self::RemoveCookie($cookie);
            return false;
        }
        return true;
    }
    public static function GetCookie($name, $domain, $remote_addr)
    {
        $name = DB::Escape($name);
        $query = DB::RunFastQuery("SELECT * FROM cms_cookies WHERE name = '{$name}' AND http_host = '{$domain}' AND remote_addr = '{$remote_addr}'");
        if ($query->NumRows() == 0) {
            return false;
        }
        $cook = new CookieElement($query->UniqueRow());
        if (!self::ValidateCookie($cook)) {
            return false;
        }
        return $cook;
    }
}
CookieManager::Init();
Ejemplo n.º 3
0
<?php

require_once '../FastInit.php';
use api\Sessions\CookieManager as CM;
use habbo\Session\HabboCookie as HC;
if (HC::HasSession()) {
    CM::RemoveCookie(HC::GetSessionData());
}