Page MenuHomePhabricator

Bot keeps losing session cookie
Closed, InvalidPublic

Description

Author: sebmol

Description:
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:
http://de.wikipedia.org/w/index.php?title=Spezial:Beitr%C3%A4ge&dir=prev&offset=20070520164842&limit=10&target=85.178.200.216

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?


Version: unspecified
Severity: normal

Details

Reference
bz9981

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:39 PM
bzimport set Reference to bz9981.
bzimport added a subscriber: Unknown Object (MLST).

marco wrote:

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
  5. Take care of the action=submitlogin&type=login in the URI
  6. Send the dewiki_session cookie you just got
  7. The POST data: wpRemember=1&wpName=USER&wpPassword=PASSWORD&wpLoginattempt=Anmelden
  8. Of course replace the placeholders; do not forget to urlencode() them.
  9. 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=/

  1. 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!

Marco

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.