Last modified: 2009-12-09 15:04:47 UTC
For about a week now my bots keep losing session information. Until now, the bot would open special:userlogin at the start of a run, keep the cookie it gets and send it with each edit. For some reason, this doesn't seem to always work anymore. A good example of what happens can be shown here:
1.) logged on: http://de.wikipedia.org/w/index.php?title=Spezial:Beitr%C3%A4ge&dir=prev&offset=20070520165517&limit=6&contribs=user&target=Sebbot
2.) suddenly logged off:
There are no IP changes and a delay of no more than 20 seconds between the edit with and without login information. Is there something I should do differently so this doesn't happen anymore?
You have to request Spezial:Anmelden twice.
1) a normal HTTP request to http://de.wikipedia.org/wiki/Spezial:Anmelden *without* sending any form of cookies, POST or GET data
2) you get a session cookie. formed like this:
Set-Cookie: dewiki_session=blablablablubblub; path=/
3) Take the cookie and remember it.
4) Send a HTTP POST request to http://de.wikipedia.org/w/index.php?title=Spezial:Anmelden&action=submitlogin&type=login with following details
- Take care of the action=submitlogin&type=login in the URI
- Send the dewiki_session cookie you just got
- The POST data: wpRemember=1&wpName=USER&wpPassword=PASSWORD&wpLoginattempt=Anmelden
- Of course replace the placeholders; do not forget to urlencode() them.
5) You get three additional cookies back with the success message:
Set-Cookie: dewikiUserID=blub; expires=Sun, 15-Jul-2007 19:15:55 GMT; path=/
Set-Cookie: dewikiUserName=blub; expires=Sun, 15-Jul-2007 19:15:55 GMT; path=/
Set-Cookie: dewikiToken=blubblubblabla; expires=Sun, 15-Jul-2007 19:15:55 GMT; path=/
6) Include these cookies AND the dewiki_session cookie you got in 2) at *EVERY* request you do, regardless if you read only or submit a edit. Note you *must not* take care of the EXPIRES attribute!
Marking INVALID because A) partly seems like user error, B) WFM, C) because you should be using the API for bots by now and D) bugs in the API would go elsewhere.