如何在Safari和Edge中存储cookie变量?

时间:2018-06-06 10:31:11

标签: javascript php cookies safari microsoft-edge

用于存储Cookie的JavaScript:

function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires="+ d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=<?= site_url() ?>Portal/";
    //Cookies.set(cname, cvalue, { expires: expires });
}

PHP:

if(!isset($_COOKIE["apikey"])) 
{
    redirect('/Login', 'refresh');  
}   

上述代码适用于除Edge和Safari之外的所有浏览器。

0 个答案:

没有答案