| | 63 | |
| | 64 | == Added support for anonymous sessions == |
| | 65 | |
| | 66 | As of [518], Django has support for anonymous sessions. If you're using a Django database installation from before [518] and you want to use the Django admin, anonymous sessions or auth-based sessions, you'll need to make a few updates to your database and settings files. |
| | 67 | |
| | 68 | === Change your settings files === |
| | 69 | |
| | 70 | Add {{{"django.middleware.sessions.SessionMiddleware"}}} to the {{{MIDDLEWARE_CLASSES}}} tuple in your admin settings file. Make sure it appears before {{{"django.middleware.admin.AdminUserRequired"}}}. (The middleware classes are applied in order, and the admin middleware requires that the session middleware come first.) |
| | 71 | |
| | 72 | If you want session support any other (i.e., non-admin) Django installation, change the {{{MIDDLEWARE_CLASSES}}} setting accordingly. The order (i.e., whether it comes before or after the other installed middleware classes) doesn't matter. |
| | 73 | |
| | 74 | === Create the core_sessions database table === |
| | 75 | |
| | 76 | In PostgreSQL, use this: |
| | 77 | |
| | 78 | {{{ |
| | 79 | CREATE TABLE core_sessions ( |
| | 80 | session_key varchar(40) NOT NULL PRIMARY KEY, |
| | 81 | session_data text NOT NULL, |
| | 82 | expire_date timestamp with time zone NOT NULL |
| | 83 | ); |
| | 84 | INSERT INTO content_types (name, package, python_module_name) VALUES ('session', 'core', 'sessions'); |
| | 85 | }}} |
| | 86 | |
| | 87 | In MySQL and SQLite, use this: |
| | 88 | |
| | 89 | {{{ |
| | 90 | CREATE TABLE core_sessions ( |
| | 91 | session_key varchar(40) NOT NULL PRIMARY KEY, |
| | 92 | session_data text NOT NULL, |
| | 93 | expire_date datetime NOT NULL |
| | 94 | ); |
| | 95 | }}} |
| | 96 | |
| | 97 | === Remove old, unneeded things === |
| | 98 | |
| | 99 | Execute this SQL in your database: |
| | 100 | |
| | 101 | {{{ |
| | 102 | DROP TABLE auth_sessions; |
| | 103 | DELETE FROM content_types WHERE package = 'auth' AND python_module_name = 'sessions'; |
| | 104 | }}} |
| | 105 | |
| | 106 | Edit your settings file(s) to remove {{{AUTH_SESSION_COOKIE}}} and {{{REGISTRATION_COOKIE_DOMAIN}}}, if they exist. |