[mod_python] About retrieving cookies...

Víctor victor.gil.sepulveda at gmail.com
Thu Mar 4 10:49:18 EST 2010


Dear all,

I've got a bunch of problems using cookies. First, it seems that if
you want to store a cookie, you MUST do it before any req.write()
sentence, isn't it?

Next... I've managed to store a simple cookie named "login_cookie"
with value 100. I can see it in the cookies manager in firefox, and it
has the right value. The cookie has an expiration time of 30 days from
now.

The problem is that... it's absolutely impossible to retrieve it from
the browser.

I have a small test page with this javascript function (it uses prototype):

function accessPage(){
				new Ajax.Request(access_base_dir+'access', {
			
					method: 'post',
					
					onSuccess: function(response) {
						$("resultados").innerHTML =response.responseText;
					},
					
					onFailure:function(response) {
						$("resultados").innerHTML= "Failed to access."+response.responseText;

					}
				});
				
			}

This function just asks 'access' to return the content. 'access' looks
like this:

@_session_getter
def access(req):
	
	(logged,user_id) = getSessionData(req)
	
	all_cookies = Cookie.get_cookies(req)
	
	req.write("Access: " +str(all_cookies))

And guess what, it only writes Access: {'pysid': } , the session
cookie, but "login_cookie" is not anywhere.

My apache config for this folder is:


<Directory "htdocs/python/test">
	AddHandler mod_python .py
	PythonHandler mod_python.publisher
	PythonDebug On
</Directory>

Do you know If I'm missing anything obvious that prevents the cookie
retrieval to work?

Thanks!,
-- 

Víctor Gil Sepúlveda
E. Informatica - FIB - UPC



More information about the Mod_python mailing list