For those who is familiar with django and chrome extension. How do you do an authentication using cookies, such that when you login to your website made in django, your chrome extension will als开发者_运维技巧o login and become active? Thanks.
Your Chrome extension (through Javascript) can read the cookie created by your Django application.
You can set your cookies using a Middelware class and then read it in JavaScript (in your .js Chrome extension file).
Python code:
class CookieMiddelware:
def process_request(self, request):
cookie = request.COOKIES.get(your_cookie_name)
if cookie and not request.user.is_authenticated():
// authenticate user here
JavaScript code for reading cookie:
mycookie = document.cookie(your_cookie_name);
精彩评论