On Sat, 2008-12-13 at 14:44 -0800, Adrián Ribao wrote:
> Hello, I'm writing a script and I'd like to login into a django webapp
> using pycurl or urllib.
> I've problems with the cookies, and every time the message is: "The
> session has expired"
> 
> Does anybody know how can I make it?

You forgot to provide an example of what you are doing at the moment, so
it's a little tricky to work out what needs correcting. I'll make some
guesses:

(1) Are you remembering to include all the form fields? In particular,
that message will be triggered if you leave out the hidden field in the
form ("this_is_the_login_form=1").

(2) Are you remembering to track cookie value updates? Once you log in
-- whenever you change from an anonymous session to an authenticated one
-- Django changes the value of the cookie. That is, your session id
changes. So the cookie value that is sent when you first receive the
login form is not the same as the value that needs to be sent after
login.

All that being said, I use curl quite a bit to test interactions with
Django. My login line generally looks like:

        curl -c cookies.txt -b cookies.txt -L -d @login-form.txt 
http://localhost:8000/admin/
        
where login-form.txt contains something like

        username=malcolm&password=secret&this_is_the_login_form=1
        
I have a few other files for other common actions, too, and generally
shell script my way around the admin site and other things I am
developing in that fashion if I need to check that things haven't
changed when I'm only intended to make internal changes.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to