How do I create a cookie after login using Django?

I wonder what is the best way to create a cookie after logging into Django. I have a problem that it is necessary to store some (insensitive) user information in a cookie that will be read by another system (running on a subdomain). I need to look at something in performance, so I don't want to call the function every page request.

I tried using a login signal calling a function to set a cookie using set_cookie . But I realized I needed to return the HttpResponse to the browser. I'm not sure if using a signal is possible... What is the best approach to this problem?

+3


source to share





All Articles