Index: Trac-0.12.2/trac/env.py
===================================================================
--- Trac-0.12.2/trac/env.py	(revision 2118)
+++ Trac-0.12.2/trac/env.py	(working copy)
@@ -474,7 +474,7 @@
             cnx = self.get_db_cnx()
         cursor = cnx.cursor()
         cursor.execute("SELECT DISTINCT s.sid, n.value, e.value "
-                       "FROM session AS s "
+                       "FROM trac_tools.session AS s "
                        " LEFT JOIN session_attribute AS n ON (n.sid=s.sid "
                        "  and n.authenticated=1 AND n.name = 'name') "
                        " LEFT JOIN session_attribute AS e ON (e.sid=s.sid "
Index: Trac-0.12.2/trac/tests/env.py
===================================================================
--- Trac-0.12.2/trac/tests/env.py	(revision 2118)
+++ Trac-0.12.2/trac/tests/env.py	(working copy)
@@ -26,7 +26,7 @@
     def test_get_known_users(self):
         """Testing env.get_known_users"""
         cursor = self.db.cursor()
-        cursor.executemany("INSERT INTO session VALUES (%s,%s,0)",
+        cursor.executemany("INSERT INTO trac_tools.session VALUES (%s,%s,0)",
                            [('123', 0),('tom', 1), ('joe', 1), ('jane', 1)])
         cursor.executemany("INSERT INTO session_attribute VALUES (%s,%s,%s,%s)",
                            [('123', 0, 'email', 'a@example.com'),
Index: Trac-0.12.2/trac/upgrades/db12.py
===================================================================
--- Trac-0.12.2/trac/upgrades/db12.py	(revision 2118)
+++ Trac-0.12.2/trac/upgrades/db12.py	(working copy)
@@ -1,24 +1,24 @@
 sql = [
 #-- Some anonymous session might have been left over
-"""DELETE FROM session WHERE username='anonymous';""",
+"""DELETE FROM trac_tools.session WHERE username='anonymous';""",
 #-- Schema change: use an authenticated flag instead of separate sid/username
 #-- columns
-"""CREATE TEMPORARY TABLE session_old AS SELECT * FROM session;""",
-"""DROP TABLE session;""",
-"""CREATE TABLE session (
+"""CREATE TEMPORARY TABLE trac_tools.session_old AS SELECT * FROM trac_tools.session;""",
+"""DROP TABLE trac_tools.session;""",
+"""CREATE TABLE trac_tools.session (
         sid             text,
         authenticated   int,
         var_name        text,
         var_value       text,
         UNIQUE(sid, var_name)
 );""",
-"""INSERT INTO session(sid,authenticated,var_name,var_value)
-    SELECT DISTINCT sid,0,var_name,var_value FROM session_old
+"""INSERT INTO trac_tools.session(sid,authenticated,var_name,var_value)
+    SELECT DISTINCT sid,0,var_name,var_value FROM trac_tools.session_old
     WHERE sid IS NULL;""",
-"""INSERT INTO session(sid,authenticated,var_name,var_value)
-    SELECT DISTINCT username,1,var_name,var_value FROM session_old
+"""INSERT INTO trac_tools.session(sid,authenticated,var_name,var_value)
+    SELECT DISTINCT username,1,var_name,var_value FROM trac_tools.session_old
     WHERE sid IS NULL;""",
-"""DROP TABLE session_old;"""
+"""DROP TABLE trac_tools.session_old;"""
 ]
 
 def do_upgrade(env, ver, cursor):
Index: Trac-0.12.2/trac/upgrades/db15.py
===================================================================
--- Trac-0.12.2/trac/upgrades/db15.py	(revision 2118)
+++ Trac-0.12.2/trac/upgrades/db15.py	(working copy)
@@ -1,8 +1,8 @@
 from trac.db import Table, Column, Index, DatabaseManager
 
 def do_upgrade(env, ver, cursor):
-    cursor.execute("CREATE TEMPORARY TABLE session_old AS SELECT * FROM session")
-    cursor.execute("DROP TABLE session")
+    cursor.execute("CREATE TEMPORARY TABLE trac_tools.session_old AS SELECT * FROM trac_tools.session")
+    cursor.execute("DROP TABLE trac_tools.session")
 
     db = env.get_db_cnx()
     session_table = Table('session', key=('sid', 'authenticated', 'var_name'))[
@@ -14,7 +14,7 @@
     for stmt in db_backend.to_sql(session_table):
         cursor.execute(stmt)
 
-    cursor.execute("INSERT INTO session (sid,authenticated,var_name,var_value) "
+    cursor.execute("INSERT INTO trac_tools.session (sid,authenticated,var_name,var_value) "
                    "SELECT sid,authenticated,var_name,var_value "
-                   "FROM session_old")
-    cursor.execute("DROP TABLE session_old")
+                   "FROM trac_tools.session_old")
+    cursor.execute("DROP TABLE trac_tools.session_old")
Index: Trac-0.12.2/trac/upgrades/db18.py
===================================================================
--- Trac-0.12.2/trac/upgrades/db18.py	(revision 2118)
+++ Trac-0.12.2/trac/upgrades/db18.py	(working copy)
@@ -1,8 +1,8 @@
 from trac.db import Table, Column, Index, DatabaseManager
 
 def do_upgrade(env, ver, cursor):
-    cursor.execute("CREATE TEMPORARY TABLE session_old AS SELECT * FROM session")
-    cursor.execute("DROP TABLE session")
+    cursor.execute("CREATE TEMPORARY TABLE trac_tools.session_old AS SELECT * FROM trac_tools.session")
+    cursor.execute("DROP TABLE trac_tools.session")
     cursor.execute("CREATE TEMPORARY TABLE ticket_change_old AS SELECT * FROM ticket_change")
     cursor.execute("DROP TABLE ticket_change")
 
@@ -35,19 +35,19 @@
             cursor.execute(stmt)
 
     # Add an index to the temporary table to speed up the conversion
-    cursor.execute("CREATE INDEX session_old_sid_idx ON session_old(sid)")
+    cursor.execute("CREATE INDEX trac_tools.session_old_sid_idx ON trac_tools.session_old(sid)")
     # Insert the sessions into the new table
     db = env.get_db_cnx()
-    cursor.execute("INSERT INTO session (sid, last_visit, authenticated) "
+    cursor.execute("INSERT INTO trac_tools.session (sid, last_visit, authenticated) "
                    "SELECT distinct s.sid,COALESCE(%s,0),s.authenticated "
-                   "FROM session_old AS s LEFT JOIN session_old AS s2 "
+                   "FROM trac_tools.session_old AS s LEFT JOIN trac_tools.session_old AS s2 "
                    "ON (s.sid=s2.sid AND s2.var_name='last_visit') "
                    "WHERE s.sid IS NOT NULL"
                    % db.cast('s2.var_value', 'int'))
     cursor.execute("INSERT INTO session_attribute "
                    "(sid, authenticated, name, value) "
                    "SELECT s.sid, s.authenticated, s.var_name, s.var_value "
-                   "FROM session_old s "
+                   "FROM trac_tools.session_old s "
                    "WHERE s.var_name <> 'last_visit' AND s.sid IS NOT NULL")
 
     # Insert ticket change data into the new table
@@ -56,6 +56,6 @@
                    "SELECT ticket, time, author, field, oldvalue, newvalue "
                    "FROM ticket_change_old")
 
-    cursor.execute("DROP TABLE session_old")
+    cursor.execute("DROP TABLE trac_tools.session_old")
     cursor.execute("DROP TABLE ticket_change_old")
 
Index: Trac-0.12.2/trac/upgrades/db4.py
===================================================================
--- Trac-0.12.2/trac/upgrades/db4.py	(revision 2118)
+++ Trac-0.12.2/trac/upgrades/db4.py	(working copy)
@@ -1,12 +1,12 @@
 sql = [
-"""CREATE TABLE session (
+"""CREATE TABLE trac_tools.session (
          sid             text,
          username        text,
          var_name        text,
          var_value       text,
          UNIQUE(sid,var_name)
 );""",
-"""CREATE INDEX session_idx ON session(sid,var_name);"""
+"""CREATE INDEX session_idx ON trac_tools.session(sid,var_name);"""
 ]
 
 def do_upgrade(env, ver, cursor):
Index: Trac-0.12.2/trac/upgrades/db9.py
===================================================================
--- Trac-0.12.2/trac/upgrades/db9.py	(revision 2118)
+++ Trac-0.12.2/trac/upgrades/db9.py	(working copy)
@@ -4,17 +4,17 @@
 #-- Remove the unused lock table
 """DROP TABLE lock;""",
 #-- Separate anonymous from authenticated sessions.
-"""CREATE TEMPORARY TABLE session_old AS SELECT * FROM session;""",
-"""DELETE FROM session;""",
-"""INSERT INTO session (username,var_name,var_value)
-  SELECT username,var_name,var_value FROM session_old
-  WHERE sid IN (SELECT DISTINCT sid FROM session_old
+"""CREATE TEMPORARY TABLE trac_tools.session_old AS SELECT * FROM trac_tools.session;""",
+"""DELETE FROM trac_tools.session;""",
+"""INSERT INTO trac_tools.session (username,var_name,var_value)
+  SELECT username,var_name,var_value FROM trac_tools.session_old
+  WHERE sid IN (SELECT DISTINCT sid FROM trac_tools.session_old
     WHERE username!='anonymous' AND var_name='last_visit'
     GROUP BY username ORDER BY var_value DESC);""",
-"""INSERT INTO session (sid,username,var_name,var_value)
-  SELECT sid,username,var_name,var_value FROM session_old
+"""INSERT INTO trac_tools.session (sid,username,var_name,var_value)
+  SELECT sid,username,var_name,var_value FROM trac_tools.session_old
   WHERE username='anonymous';""",
-"""DROP TABLE session_old;"""
+"""DROP TABLE trac_tools.session_old;"""
 ]
 
 def do_upgrade(env, ver, cursor):
Index: Trac-0.12.2/trac/web/auth.py
===================================================================
--- Trac-0.12.2/trac/web/auth.py	(revision 2118)
+++ Trac-0.12.2/trac/web/auth.py	(working copy)
@@ -153,10 +153,10 @@
         @self.env.with_transaction()
         def store_session_cookie(db):
             cursor = db.cursor()
-            # Delete cookies older than 10 days
-            cursor.execute("DELETE FROM auth_cookie WHERE time < %s",
-                           (int(time.time()) - 86400 * 10,))
-            cursor.execute("INSERT INTO auth_cookie (cookie,name,ipnr,time) "
+            # Delete cookies older than 28 days
+            cursor.execute("DELETE FROM trac_tools.auth_cookie WHERE time < %s",
+                           (int(time.time()) - 86400 * 28,))
+            cursor.execute("INSERT INTO trac_tools.auth_cookie (cookie,name,ipnr,time) "
                            "VALUES (%s, %s, %s, %s)",
                            (cookie, remote_user, req.remote_addr,
                             int(time.time())))
@@ -168,6 +168,8 @@
             req.outcookie['trac_auth']['secure'] = True
         if self.auth_cookie_lifetime > 0:
             req.outcookie['trac_auth']['expires'] = self.auth_cookie_lifetime
+            
+        self.log.debug("==auth.py==>req.outcookie[trac_auth]=%s" % (req.outcookie['trac_auth']))
 
     def _do_logout(self, req):
         """Log the user out.
@@ -182,10 +184,10 @@
         def delete_session_cookie(db):
             cursor = db.cursor()
             if 'trac_auth' in req.incookie:
-                cursor.execute("DELETE FROM auth_cookie WHERE cookie=%s",
+                cursor.execute("DELETE FROM trac_tools.auth_cookie WHERE cookie=%s",
                                (req.incookie['trac_auth'].value,))
             else:
-                cursor.execute("DELETE FROM auth_cookie WHERE name=%s",
+                cursor.execute("DELETE FROM trac_tools.auth_cookie WHERE name=%s",
                                (req.authname,))
         self._expire_cookie(req)
         custom_redirect = self.config['metanav'].get('logout.redirect')
@@ -209,19 +211,21 @@
         db = self.env.get_db_cnx()
         cursor = db.cursor()
         if self.check_ip:
-            cursor.execute("SELECT name FROM auth_cookie "
-                           "WHERE cookie=%s AND ipnr=%s",
-                           (cookie.value, req.remote_addr))
+            sql = "SELECT name FROM trac_tools.auth_cookie WHERE cookie='%s' AND ipnr=%s" % (cookie.value, req.remote_addr)
         else:
-            cursor.execute("SELECT name FROM auth_cookie WHERE cookie=%s",
-                           (cookie.value,))
+            sql = "SELECT name FROM trac_tools.auth_cookie WHERE cookie='%s'" % (cookie.value,)
+        
+        self.log.debug("==_get_name_for_cookie==>sql=%s" % (sql))
+        cursor.execute(sql)
         row = cursor.fetchone()
         if not row:
+            self.log.debug("==_get_name_for_cookie==>not found")
             # The cookie is invalid (or has been purged from the database), so
             # tell the user agent to drop it as it is invalid
             self._expire_cookie(req)
             return None
 
+        self.log.debug("==_get_name_for_cookie==>row[0]=%s" % (row[0]))
         return row[0]
 
     def _redirect_back(self, req):
Index: Trac-0.12.2/trac/web/tests/auth.py
===================================================================
--- Trac-0.12.2/trac/web/tests/auth.py	(revision 2118)
+++ Trac-0.12.2/trac/web/tests/auth.py	(working copy)
@@ -34,7 +34,7 @@
 
     def test_known_cookie_access(self):
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO auth_cookie (cookie, name, ipnr) "
+        cursor.execute("INSERT INTO trac_tools.auth_cookie (cookie, name, ipnr) "
                        "VALUES ('123', 'john', '127.0.0.1')")
         incookie = Cookie()
         incookie['trac_auth'] = '123'
@@ -48,7 +48,7 @@
     def test_known_cookie_ip_check_enabled(self):
         self.env.config.set('trac', 'check_auth_ip', 'yes')
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO auth_cookie (cookie, name, ipnr) "
+        cursor.execute("INSERT INTO trac_tools.auth_cookie (cookie, name, ipnr) "
                        "VALUES ('123', 'john', '127.0.0.1')")
         incookie = Cookie()
         incookie['trac_auth'] = '123'
@@ -63,7 +63,7 @@
     def test_known_cookie_ip_check_disabled(self):
         self.env.config.set('trac', 'check_auth_ip', 'no')
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO auth_cookie (cookie, name, ipnr) "
+        cursor.execute("INSERT INTO trac_tools.auth_cookie (cookie, name, ipnr) "
                        "VALUES ('123', 'john', '127.0.0.1')")
         incookie = Cookie()
         incookie['trac_auth'] = '123'
@@ -87,7 +87,7 @@
         assert outcookie.has_key('trac_auth'), '"trac_auth" Cookie not set'
         auth_cookie = outcookie['trac_auth'].value
         cursor = self.db.cursor()
-        cursor.execute("SELECT name,ipnr FROM auth_cookie WHERE cookie=%s",
+        cursor.execute("SELECT name,ipnr FROM trac_tools.auth_cookie WHERE cookie=%s",
                        (auth_cookie,))
         row = cursor.fetchone()
         self.assertEquals('john', row[0])
@@ -110,7 +110,7 @@
         assert outcookie.has_key('trac_auth'), '"trac_auth" Cookie not set'
         auth_cookie = outcookie['trac_auth'].value
         cursor = self.db.cursor()
-        cursor.execute("SELECT name,ipnr FROM auth_cookie WHERE cookie=%s",
+        cursor.execute("SELECT name,ipnr FROM trac_tools.auth_cookie WHERE cookie=%s",
                        (auth_cookie,))
         row = cursor.fetchone()
         self.assertEquals('john', row[0])
@@ -124,7 +124,7 @@
 
     def test_already_logged_in_same_user(self):
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO auth_cookie (cookie, name, ipnr) "
+        cursor.execute("INSERT INTO trac_tools.auth_cookie (cookie, name, ipnr) "
                        "VALUES ('123', 'john', '127.0.0.1')")
         incookie = Cookie()
         incookie['trac_auth'] = '123'
@@ -135,7 +135,7 @@
 
     def test_already_logged_in_different_user(self):
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO auth_cookie (cookie, name, ipnr) "
+        cursor.execute("INSERT INTO trac_tools.auth_cookie (cookie, name, ipnr) "
                        "VALUES ('123', 'john', '127.0.0.1')")
         incookie = Cookie()
         incookie['trac_auth'] = '123'
@@ -146,7 +146,7 @@
 
     def test_logout(self):
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO auth_cookie (cookie, name, ipnr) "
+        cursor.execute("INSERT INTO trac_tools.auth_cookie (cookie, name, ipnr) "
                        "VALUES ('123', 'john', '127.0.0.1')")
         incookie = Cookie()
         incookie['trac_auth'] = '123'
@@ -157,7 +157,7 @@
                    base_path='/trac.cgi')
         self.module._do_logout(req)
         self.failIf('trac_auth' not in outcookie)
-        cursor.execute("SELECT name,ipnr FROM auth_cookie WHERE name='john'")
+        cursor.execute("SELECT name,ipnr FROM trac_tools.auth_cookie WHERE name='john'")
         self.failIf(cursor.fetchone())
 
     def test_logout_not_logged_in(self):
Index: Trac-0.12.2/trac/web/tests/session.py
===================================================================
--- Trac-0.12.2/trac/web/tests/session.py	(revision 2118)
+++ Trac-0.12.2/trac/web/tests/session.py	(working copy)
@@ -15,7 +15,7 @@
     Return a tuple of lists: (auth_list, anon_list, all_list)
     """
     cursor = db.cursor()
-    cursor.execute("DELETE FROM session")
+    cursor.execute("DELETE FROM trac_tools.session")
     cursor.execute("DELETE FROM session_attribute")
     last_visit_base = time.mktime(datetime(2010, 1, 1).timetuple())
     visit_delta = spread_visits and 86400 or 0
@@ -30,7 +30,7 @@
             auth_list.append(data)
         else:
             anon_list.append(data)
-        cursor.execute("INSERT INTO session VALUES (%s, %s, %s)",
+        cursor.execute("INSERT INTO trac_tools.session VALUES (%s, %s, %s)",
                        (sid, authenticated, last_visit))
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "(%s, %s, 'name', %s)",
@@ -46,7 +46,7 @@
 def get_session_info(db, sid):
     cursor = db.cursor()
     cursor.execute("SELECT DISTINCT s.sid, n.value, e.value "
-                   "  FROM session AS s "
+                   "  FROM trac_tools.session AS s "
                    " LEFT JOIN session_attribute AS n ON (n.sid=s.sid "
                    "  AND n.name = 'name') "
                    " LEFT JOIN session_attribute AS e ON (e.sid=s.sid "
@@ -80,7 +80,7 @@
         session = Session(self.env, req)
         self.assertEqual(session.sid, cookie['trac_session'].value)
         cursor = self.db.cursor()
-        cursor.execute("SELECT COUNT(*) FROM session")
+        cursor.execute("SELECT COUNT(*) FROM trac_tools.session")
         self.assertEqual(0, cursor.fetchone()[0])
 
     def test_anonymous_session(self):
@@ -118,7 +118,7 @@
         authenticated session when the user logs in.
         """
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('123456', 0, 0)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('123456', 0, 0)")
         incookie = Cookie()
         incookie['trac_session'] = '123456'
         outcookie = Cookie()
@@ -128,7 +128,7 @@
         self.assertEqual('john', session.sid)
         session.save()
 
-        cursor.execute("SELECT sid,authenticated FROM session")
+        cursor.execute("SELECT sid,authenticated FROM trac_tools.session")
         self.assertEqual(('john', 1), cursor.fetchone())
         self.assertEqual(None, cursor.fetchone())
 
@@ -148,7 +148,7 @@
         self.assertEqual('john', session.sid)
         session.save()
 
-        cursor.execute("SELECT sid,authenticated FROM session")
+        cursor.execute("SELECT sid,authenticated FROM trac_tools.session")
         self.assertEqual(('john', 1), cursor.fetchone())
         self.assertEqual(None, cursor.fetchone())
 
@@ -174,7 +174,7 @@
         accordingly for an anonymous session.
         """
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('123456', 0, 0)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('123456', 0, 0)")
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "('123456', 0, 'foo', 'bar')")
         incookie = Cookie()
@@ -194,7 +194,7 @@
         for an anonymous session.
         """
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('123456', 0, 0)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('123456', 0, 0)")
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "('123456', 0, 'foo', 'bar')")
         incookie = Cookie()
@@ -214,10 +214,10 @@
         Verify that old sessions get purged.
         """
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session "
+        cursor.execute("INSERT INTO trac_tools.session "
                        "VALUES ('123456', 0, %s)",
                        (0,))
-        cursor.execute("INSERT INTO session "
+        cursor.execute("INSERT INTO trac_tools.session "
                        "VALUES ('987654', 0, %s)",
                        (int(time.time() - PURGE_AGE - 3600),))
         cursor.execute("INSERT INTO session_attribute VALUES "
@@ -232,7 +232,7 @@
         session['foo'] = 'bar'
         session.save()
 
-        cursor.execute("SELECT COUNT(*) FROM session WHERE sid='987654' AND "
+        cursor.execute("SELECT COUNT(*) FROM trac_tools.session WHERE sid='987654' AND "
                        "authenticated=0")
         self.assertEqual(0, cursor.fetchone()[0])
 
@@ -245,7 +245,7 @@
 
         # Make sure the session has data so that it doesn't get dropped
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session "
+        cursor.execute("INSERT INTO trac_tools.session "
                        "VALUES ('123456', 0, %s)",
                        (int(now - UPDATE_INTERVAL - 3600),))
         cursor.execute("INSERT INTO session_attribute VALUES "
@@ -259,7 +259,7 @@
         del session['foo']
         session.save()
 
-        cursor.execute("SELECT COUNT(*) FROM session WHERE sid='123456' AND "
+        cursor.execute("SELECT COUNT(*) FROM trac_tools.session WHERE sid='123456' AND "
                        "authenticated=0")
         self.assertEqual(0, cursor.fetchone()[0])
 
@@ -271,7 +271,7 @@
         """
 
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('123456', 0, 0)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('123456', 0, 0)")
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "('123456', 0, 'foo', 'bar')")
 
@@ -287,7 +287,7 @@
         session.save()
         self.assertEqual({'baz': 'moo'}, session)
 
-        cursor.execute("SELECT COUNT(*) FROM session WHERE sid='7890' AND "
+        cursor.execute("SELECT COUNT(*) FROM trac_tools.session WHERE sid='7890' AND "
                        "authenticated=0")
         self.assertEqual(1, cursor.fetchone()[0])
         cursor.execute("SELECT name, value FROM session_attribute "
@@ -314,7 +314,7 @@
         accordingly for an authenticated session.
         """
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('john', 1, 0)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('john', 1, 0)")
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "('john', 1, 'foo', 'bar')")
 
@@ -333,7 +333,7 @@
         session doesn't interfere with the latter.
         """
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('john', 1, 0)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('john', 1, 0)")
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "('john', 1, 'foo', 'bar')")
 
@@ -367,7 +367,7 @@
         for an authenticated session.
         """
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('john', 1, 0)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('john', 1, 0)")
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "('john', 1, 'foo', 'bar')")
 
@@ -389,7 +389,7 @@
 
         # Make sure the session has data so that it doesn't get dropped
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('123456', 0, 1)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('123456', 0, 1)")
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "('123456', 0, 'foo', 'bar')")
 
@@ -404,7 +404,7 @@
 
         self.assertEqual(PURGE_AGE, outcookie['trac_session']['expires'])
 
-        cursor.execute("SELECT last_visit FROM session WHERE sid='123456' AND "
+        cursor.execute("SELECT last_visit FROM trac_tools.session WHERE sid='123456' AND "
                        "authenticated=0")
         self.assertAlmostEqual(now, int(cursor.fetchone()[0]), -1)
 
@@ -414,7 +414,7 @@
         request updates the database accordingly.
         """
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('john', 1, 0)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('john', 1, 0)")
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "('john', 1, 'foo', 'bar')")
 
@@ -432,7 +432,7 @@
         request deletes the variable from the database.
         """
         cursor = self.db.cursor()
-        cursor.execute("INSERT INTO session VALUES ('john', 1, 0)")
+        cursor.execute("INSERT INTO trac_tools.session VALUES ('john', 1, 0)")
         cursor.execute("INSERT INTO session_attribute VALUES "
                        "('john', 1, 'foo', 'bar')")
 
Index: Trac-0.12.2/trac/web/session.py
===================================================================
--- Trac-0.12.2/trac/web/session.py	(revision 2118)
+++ Trac-0.12.2/trac/web/session.py	(working copy)
@@ -66,7 +66,7 @@
         self.clear()
 
         cursor.execute("""
-            SELECT last_visit FROM session WHERE sid=%s AND authenticated=%s
+            SELECT last_visit FROM trac_tools.session WHERE sid=%s AND authenticated=%s
             """, (sid, int(authenticated)))
         row = cursor.fetchone()
         if not row:
@@ -117,7 +117,7 @@
                 # it could have been created by a concurrent request (#3563).
                 try:
                     cursor.execute("""
-                        INSERT INTO session (sid,last_visit,authenticated)
+                        INSERT INTO trac_tools.session (sid,last_visit,authenticated)
                         VALUES (%s,%s,%s)
                         """, (self.sid, self.last_visit, authenticated))
                 except Exception:
@@ -132,7 +132,7 @@
                 if not items and not authenticated:
                     # No need to keep around empty unauthenticated sessions
                     cursor.execute("""
-                        DELETE FROM session WHERE sid=%s AND authenticated=0
+                        DELETE FROM trac_tools.session WHERE sid=%s AND authenticated=0
                         """, (self.sid,))
                 cursor.execute("""
                     DELETE FROM session_attribute
@@ -160,14 +160,14 @@
                 # hour old, so that session doesn't get purged
                 self.env.log.info("Refreshing session %s", self.sid)
                 cursor.execute("""
-                    UPDATE session SET last_visit=%s
+                    UPDATE trac_tools.session SET last_visit=%s
                     WHERE sid=%s AND authenticated=%s
                     """, (self.last_visit, self.sid, authenticated))
                 self.env.log.debug('Purging old, expired, sessions.')
                 cursor.execute("""
                     DELETE FROM session_attribute
                     WHERE authenticated=0 AND sid IN (
-                      SELECT sid FROM session 
+                      SELECT sid FROM trac_tools.session 
                       WHERE authenticated=0 AND last_visit < %s
                     )
                     """, (mintime,))
@@ -178,7 +178,7 @@
             def purge_sessions(db):
                 cursor = db.cursor()
                 cursor.execute("""
-                    DELETE FROM session
+                    DELETE FROM trac_tools.session
                     WHERE authenticated=0 AND last_visit < %s
                     """, (mintime,))
 
@@ -233,7 +233,7 @@
         @self.env.with_transaction()
         def update_session_id(db):
             cursor = db.cursor()
-            cursor.execute("SELECT sid FROM session WHERE sid=%s", (new_sid,))
+            cursor.execute("SELECT sid FROM trac_tools.session WHERE sid=%s", (new_sid,))
             if cursor.fetchone():
                 raise TracError(_("Session '%(id)s' already exists. "
                                   "Please choose a different session ID.",
@@ -242,7 +242,7 @@
             self.env.log.debug('Changing session ID %s to %s', self.sid,
                                new_sid)
             cursor.execute("""
-                UPDATE session SET sid=%s WHERE sid=%s AND authenticated=0
+                UPDATE trac_tools.session SET sid=%s WHERE sid=%s AND authenticated=0
                   """, (new_sid, self.sid))
             cursor.execute("""
                 UPDATE session_attribute SET sid=%s 
@@ -262,7 +262,7 @@
         def update_session_id(db):
             cursor = db.cursor()
             cursor.execute("""
-                SELECT authenticated FROM session WHERE sid=%s OR sid=%s
+                SELECT authenticated FROM trac_tools.session WHERE sid=%s OR sid=%s
                 """, (sid, self.req.authname))
             authenticated_flags = [row[0] for row in cursor.fetchall()]
             
@@ -270,7 +270,7 @@
                 # There's already an authenticated session for the user,
                 # we simply delete the anonymous session
                 cursor.execute("""
-                    DELETE FROM session WHERE sid=%s AND authenticated=0
+                    DELETE FROM trac_tools.session WHERE sid=%s AND authenticated=0
                     """, (sid,))
                 cursor.execute("""
                     DELETE FROM session_attribute
@@ -284,7 +284,7 @@
                                        'authenticated session for user %s',
                                        sid, self.req.authname)
                     cursor.execute("""
-                        UPDATE session SET sid=%s,authenticated=1
+                        UPDATE trac_tools.session SET sid=%s,authenticated=1
                         WHERE sid=%s AND authenticated=0
                         """, (self.req.authname, sid))
                     cursor.execute("""
@@ -294,7 +294,7 @@
             else:
                 # we didn't have an anonymous session for this sid
                 cursor.execute("""
-                    INSERT INTO session (sid,last_visit,authenticated)
+                    INSERT INTO trac_tools.session (sid,last_visit,authenticated)
                     VALUES (%s,%s,1)
                     """, (self.req.authname, int(time.time())))
         self._new = False
@@ -366,7 +366,7 @@
     def _get_sids(self):
         db = self.env.get_db_cnx()
         cursor = db.cursor()
-        cursor.execute("SELECT sid, authenticated FROM session")
+        cursor.execute("SELECT sid, authenticated FROM trac_tools.session")
         return ['%s:%d' % (sid, auth) for sid, auth in cursor]
 
     def _get_list(self, sids):
@@ -379,7 +379,7 @@
         cursor.execute("""
             SELECT DISTINCT s.sid, s.authenticated, s.last_visit,
                             n.value, e.value
-            FROM session AS s
+            FROM trac_tools.session AS s
               LEFT JOIN session_attribute AS n
                 ON (n.sid=s.sid AND n.authenticated=s.authenticated
                     AND n.name='name')
@@ -423,7 +423,7 @@
         def add_session(db):
             cursor = db.cursor()
             try:
-                cursor.execute("INSERT INTO session VALUES (%s, %s, %s)",
+                cursor.execute("INSERT INTO trac_tools.session VALUES (%s, %s, %s)",
                                (sid, authenticated, int(time.time())))
             except Exception:
                 raise AdminCommandError(_("Session '%(sid)s' already exists",
@@ -446,7 +446,7 @@
         def set_attr(db):
             cursor = db.cursor()
             cursor.execute("""
-                SELECT sid FROM session WHERE sid=%s AND authenticated=%s
+                SELECT sid FROM trac_tools.session WHERE sid=%s AND authenticated=%s
                 """, (sid, authenticated))
             if not cursor.fetchone():
                 raise AdminCommandError(_("Session '%(sid)s' not found",
@@ -467,14 +467,14 @@
                 sid, authenticated = self._split_sid(sid)
                 if sid == 'anonymous':
                     cursor.execute("""
-                        DELETE FROM session WHERE authenticated=0
+                        DELETE FROM trac_tools.session WHERE authenticated=0
                         """)
                     cursor.execute("""
                         DELETE FROM session_attribute WHERE authenticated=0
                         """)
                 else:
                     cursor.execute("""
-                        DELETE FROM session
+                        DELETE FROM trac_tools.session
                         WHERE sid=%s AND authenticated=%s
                         """, (sid, authenticated))
                     cursor.execute("""
@@ -489,12 +489,12 @@
             cursor = db.cursor()
             ts = to_timestamp(when)
             cursor.execute("""
-                DELETE FROM session
+                DELETE FROM trac_tools.session
                 WHERE authenticated=0 AND last_visit<%s
                 """, (ts,))
             cursor.execute("""
                 DELETE FROM session_attribute
                 WHERE authenticated=0
-                      AND sid IN (SELECT sid FROM session
+                      AND sid IN (SELECT sid FROM trac_tools.session
                                   WHERE authenticated=0 AND last_visit<%s)
                 """, (ts,))
Index: accountmanagerplugin-remember-me/trunk.LdapAuthStore/acct_mgr/api.py
===================================================================
--- accountmanagerplugin-remember-me/trunk.LdapAuthStore/acct_mgr/api.py	(revision 2158)
+++ accountmanagerplugin-remember-me/trunk.LdapAuthStore/acct_mgr/api.py	(working copy)
@@ -231,7 +231,7 @@
         cursor = db.cursor()
         cursor.execute("""
             SELECT *
-              FROM session
+              FROM trac_tools.session
              WHERE authenticated=1 AND sid=%s
             """, (user,))
         for row in cursor:
@@ -243,7 +243,7 @@
         cursor = db.cursor()
         sql = """
             SELECT sid,last_visit
-              FROM session
+              FROM trac_tools.session
              WHERE authenticated=1
             """
         if user:
@@ -289,7 +289,7 @@
         # Delete session attributes 
         cursor.execute("DELETE FROM session_attribute where sid=%s", (user,))
         # Delete session 
-        cursor.execute("DELETE FROM session where sid=%s", (user,))
+        cursor.execute("DELETE FROM trac_tools.session where sid=%s", (user,))
         # Delete any custom permissions set for the user 
         cursor.execute("DELETE FROM permission where username=%s", (user,))
         db.commit()
Index: accountmanagerplugin-remember-me/trunk.LdapAuthStore/acct_mgr/web_ui.py
===================================================================
--- accountmanagerplugin-remember-me/trunk.LdapAuthStore/acct_mgr/web_ui.py	(revision 2158)
+++ accountmanagerplugin-remember-me/trunk.LdapAuthStore/acct_mgr/web_ui.py	(working copy)
@@ -21,7 +21,7 @@
 
 from trac import perm, util
 from trac.core import *
-from trac.config import Configuration, IntOption, BoolOption
+from trac.config import Configuration, IntOption, BoolOption, Option
 from trac.prefs import IPreferencePanelProvider
 from trac.util.presentation import separated
 from trac.web import auth
@@ -146,12 +146,12 @@
 
     db = env.get_db_cnx()
     cursor = db.cursor()
-    cursor.execute("SELECT count(*) FROM session "
+    cursor.execute("SELECT count(*) FROM trac_tools.session "
                    "WHERE sid=%s AND authenticated=1",
                    (user,))
     exists, = cursor.fetchone()
     if not exists:
-        cursor.execute("INSERT INTO session "
+        cursor.execute("INSERT INTO trac_tools.session "
                        "(sid, authenticated, last_visit) "
                        "VALUES (%s, 1, 0)",
                        (user,))
@@ -470,6 +470,11 @@
 
     implements(ITemplateProvider)
 
+    auth_cookie_path = Option('trac', 'auth_cookie_path', '',
+        """Path for the authentication cookie. Set this to the common base path
+        of several Trac instances if you want them to share the cookie.
+        (''since 0.12'')""")
+
     def authenticate(self, req):
         if req.method == 'POST' and req.path_info.startswith('/login'):
             user = self._remote_user(req)
@@ -594,7 +599,7 @@
             # Refresh in database
             db = self.env.get_db_cnx()
             cursor = db.cursor()
-            cursor.execute('UPDATE auth_cookie SET time=%s WHERE cookie=%s',
+            cursor.execute('UPDATE trac_tools.auth_cookie SET time=%s WHERE cookie=%s',
                             (int(time.time()), cookie.value))
             db.commit()
             
@@ -603,14 +608,14 @@
             #   never would change at all (i.e. stay the same indefinitely and
             #   therefore is vulnerable to be hacked).
             req.outcookie['trac_auth'] = cookie.value
-            req.outcookie['trac_auth']['path'] = req.base_path or '/'
-            req.outcookie['trac_auth']['expires'] = 86400 * 30
+            req.outcookie['trac_auth']['path'] = self.auth_cookie_path or req.base_path or '/'
+            req.outcookie['trac_auth']['expires'] = 86400 * 90
             if self.env.secure_cookies:
                 req.outcookie['trac_auth']['secure'] = True
                 
             req.outcookie['trac_auth_session'] = 1
-            req.outcookie['trac_auth_session']['path'] = req.base_path or '/'
-            req.outcookie['trac_auth_session']['expires'] = 86400 * 30
+            req.outcookie['trac_auth_session']['path'] = self.auth_cookie_path or req.base_path or '/'
+            req.outcookie['trac_auth_session']['expires'] = 86400 * 90
 
         return name
 
@@ -620,17 +625,18 @@
             self._redirect_back(req)
         res = auth.LoginModule._do_login(self, req)
         if req.args.get('rememberme', '0') == '1':
-            # Set the session to expire in 30 days (and not when to browser is
+            # Set the session to expire in 90 days (and not when to browser is
             # closed - what is the default).
-            req.outcookie['trac_auth']['expires'] = 86400 * 30
+            req.outcookie['trac_auth']['expires'] = 86400 * 90
             
             # This cookie is used to indicate that the user is actually using
             # the "Remember me" feature. This is necessary for 
             # '_get_name_for_cookie()'.
             req.outcookie['trac_auth_session'] = 1
-            req.outcookie['trac_auth_session']['path'] = req.base_path or '/'
-            req.outcookie['trac_auth_session']['expires'] = 86400 * 30
-            
+            req.outcookie['trac_auth_session']['path'] = self.auth_cookie_path or req.base_path or '/'
+            req.outcookie['trac_auth_session']['expires'] = 86400 * 90
+            self.log.debug("====>req.outcookie[trac_auth_session]=%s" % (req.outcookie['trac_auth_session']))
+
         return res
 
     # overrides
@@ -639,7 +645,7 @@
         
         # Expire the persistent session cookie
         req.outcookie['trac_auth_session'] = ''
-        req.outcookie['trac_auth_session']['path'] = req.base_path or '/'
+        req.outcookie['trac_auth_session']['path'] = self.auth_cookie_path or req.base_path or '/'
         req.outcookie['trac_auth_session']['expires'] = -10000
 
     def _remote_user(self, req):
