Trac: Automatic Login Hack

KarmaDude Feb 26, 2007 Add comment

TracBy default Trac login is set to expire at the end of a session. This means that every time you reopen the browser, you have to re-login to Trac. This can be annoying if you are a regular Trac user.

So to fix this, you will have to set a future expiry date for the trac_auth cookie. Here are the steps:

  1. Open auth.py file. This file can be found under your Trac installations web folder.
  2. Find line containing following code (about line 149 for Trac v0.10.3)req.outcookie['trac_auth']['path'] = req.href()
  3. Insert after the following line. Here I have set the expiry date to a date 20 years from the current date. req.outcookie['trac_auth']['expires'] = 3600*24*365*20
  4. Open your Trac page in your browser, and login. From now you will be automatically logged into to Trac.

This is a change to the core source, so be sure to keep track of this change whenever you upgrade Trac.

Leave a Comment

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>