[mod_python] cookies and redirects

michael bayer mike_mp at zzzcomputing.com
Sat Nov 6 11:11:03 EST 2004


an internal redirect is within the context of a single request; apache 
hasnt closed the original connection or anything.  If you want to see a 
cookie you just set, its still there in the response headers you set 
up...just pull it out again !

but i guess you are looking to see that the browser successfully 
accepted the cookie by seeing if it comes back again.  in that case you 
have to use an external redirect of some kind, yes.



On Nov 6, 2004, at 4:28 AM, John Aherne wrote:

> mike bayer wrote:
>
>>> John Aherne wrote:
>>> External redirect, particularly a 307 redirect for HTTP/1.1 clients, 
>>> is
>>> generally the best way to handle changing a location in response to a
>>> request.  Using a 307 means the client's back button works right, 
>>> reload
>>> works right, and the URL location bar works right.
>>>
>>>
>>
>> I have never seen a 307 redirect used before, so I will admit my 
>> ignorance
>> of it as well as its usablity.  But big sites like Yahoo! etc. use 
>> "302
>> Found" combined with the Location: header (I just double checked) to 
>> send
>> the client elsewhere, as does the "Redirect" directive in Apache.
>>
>> Which is not to say the 307 is not a better way, but is it very well
>> supported and predictable across all browsers ?
>>
>> If you really want a seamless redirect with zero side effects, an 
>> internal
>> redirect, i.e. an server-side change of output within the scope of one
>> request, is best, if your application can support them.
>>
>> Also, an external redirect is often used specifically to prevent 
>> reloads
>> and back button usage, as in the case of an ecommerce submit form 
>> that you
>> dont want submitted a second time by accident.
>>
>> I tend to use external redirects only for that reason, i.e. to prevent
>> form reloads, and otherwise internal redirects for everything else, 
>> which
>> are particularly useful since you can more easily preserve the request
>> state among the original and redirected pages.
>>
>> - mike
>>
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>
>>
> Am I mistaken. But I thought I needed to do an external rediect to get 
> back the cookie I had just set from the browser.
>
> I assumed that an internal redirect would not do this.
>
> John Aherne
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python


More information about the Mod_python mailing list