I am trying to figure out how to set a cookie just before a redirect from Cherrypy. My situation is this:  

when a user logs in, I would like to set a cookie with the users username for use in
client-side code (specifically, inserting the users name into each
page to show who is currently logged in).

The way my login system works is that after a successful login, the user is redirected to whatever page they were trying to access before logging in, or the default page. Technically they are redirected to a different domain, since the login page is secure while the rest of the site is not, but it is all on the same site/hostname. Redirection is accomplished by raising a cherrypy.HTTPRedirect(). I would like to set the cookie either just before or just after the redirect, but when I tried setting cherrypy.response.cookie[<tag>]=<value> before the redirect, it does nothing. At the moment I have resorted to setting the cookie in every index page of my site, in the hopes that that will cover most of the redirect options, but I don't like this solution. Is there a better option, and if so what?
To answer my own question: It would appear that if I add cherrypy.response.cookie[<tag>]['path'] = '/' after setting the cookie value, it works as desired.
Python/Cherrypy: set cookie on redirect