<?php
namespace Biz\Account;
class Invite{

    static function init(){
        $name= __NAMESPACE__.'\\'.__CLASS__;
        if(!C()->has($name)){
            C()->set($name, new self()); 
        }
        return C()->get($name);       
    }

    public function getInviteId(){
        $id = isset($_SESSION['invite']) ? intval($_SESSION['invite']) : 0;
        return isset($_COOKIE['invite']) && $id < 1 ? intval($_COOKIE['invite']) : $id;
    }

    public function setInviteId($id){
        $_SESSION['invite'] = intval($id);
        $_COOKIE['invite'] = intval($id);
    }

    //新版代理邀请码存储2018-12-08 anton liu
    public function getInvitaId(){
        $id = isset($_SESSION['invita']) ? $_SESSION['invita'] : '';
        return isset($_COOKIE['invita']) && $id ? $_COOKIE['invita'] : $id;
    }

    public function setInvitaId($invita){
        $_SESSION['invita'] = $invita;
        $_COOKIE['invita'] = $invita;
    }
}