There is already a solution for drupal:
https://www.dokuwiki.org/auth:mysql_drupal
Anyway imho dokuwiki should keep track of the user after a login. You can have a look at
https://github.com/splitbrain/dokuwiki/blob/master/lib/plugins/authmysql/auth.php. this is the current implementation of the mysql auth plugin to the solution above.