简体   繁体   中英

Chrome Extensions and Cookies

I've created a chrome extension and I'm trying to use it to allow a user to log into a system. I'm setting a cookie using chrome.cookies.set and then I'm trying to read it with PHP - but PHP never seems to see the cookie as being set. I've manually verified that the cookie exists but isset() always seems to be returning false.

chrome.cookies.set({"name":"username","url":"http://127.0.0.1","domain":null, "path": "/", "value":userName},function (cookie){
  console.log(JSON.stringify(cookie));
  console.log(chrome.extension.lastError);
  console.log(chrome.runtime.lastError);
});

That's how I'm setting the cookie and this is how I'm trying to fetch it with PHP:

<?php
    if(isset($_COOKIE["username"])){
        echo "Logged in";
    }
?>

Any ideas? This has had me stumped for a while now.

好吧,我从未解决过Cookie的确切问题,我决定改用OAuth进行身份验证。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM