[mod_python] Setting the cookie domain name using mod_python's Cookie class

Graham Dumpleton graham.dumpleton at gmail.com
Tue Mar 2 18:11:34 EST 2010


On 3 March 2010 01:36, L.Guruprasad <lgp171188 at gmail.com> wrote:
> Hi all,
> Is it possible to set the domain for which a cookie is valid using
> mod_python's Cookie class? I need to know about this because I want to
> share cookies between 2 subdomains of a common superdomain.
>
> This is how my workflow goes:
>
> Login into Web app1 -> Authenticates and sets cookie for
> subdomain1.domain.com.
>
> Open Web app2 -> Check for session cookie, if it isn't there, redirect
> to web app1 with referring_url set to web-app2 domain. Web app1, checks
> for cookie in the browser which will be there if the user has logged in.
> It takes the session id and sees if user of that session id has
> privilege for app2 and if it is true, it sets cookie for
> subdomain2.domain.com and redirects to the initially set referrer_url.
>
> Is this possible with mod_python?

The documentation mentions the 'domain' attribute is available.

http://www.modpython.org/live/current/doc-html/pyapi-cookie-classes.html

Read some general documentation about cookies to work out what it can be set to.

In short, by default you cannot share a cookie between two distinct
hosts, you can however share it across hosts in same parent domain by
setting the 'domain' to the parent domain.

Graham


More information about the Mod_python mailing list