- time: documentation ( source)
- sha1: documentation ( source)
- setcookie: documentation ( source)
- base64_encode: documentation ( source)
<?php
class MonsterTalk
{
const VERSION = "1.0.1";
protected $namespace = "MonsterTalk";
public function __construct($userId, $domainKey, $salt)
{
$this->userId = $userId;
$this->domainKey = $domainKey;
$this->salt = $salt;
$this->token;
$this->authorize();
}
public function authorize()
{
if (!isset($_COOKIE["__dugalu_token"])){
$token = sha1($this->userId . "@" . $this->salt);
$data = base64_encode('userId=' . $this->userId . "&domainKey=" . $this->domainKey . "&token=" . $token);
echo $data;
setcookie("__dugalu_auth", $data, time()+(60*60*24*30));
} else{
echo 'Existe el cookie';
}
// $cookie = $this->genCookie();
}
public function genCookie()
{
$token = sha1($this->userId . "@" . $this->privateKey);
return $this->$name;
}
}