Difference between revisions of "PersistentSessions"

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
(No difference)

Revision as of 16:20, 6 April 2016

If you would like to alleviate the need to constantly log in every time you close your browser, you can make the sessions persistent by modifying the cookie set to record the session ID. In the file Elements/SetupSessionCookie modify this code (near the bottom):

if ( !$cookies{$cookiename} ) {
    my $cookie = new CGI::Cookie(
        -name  => $cookiename,
        -value => $session{_session_id},
        -path  => $RT::WebPath,
        -secure => ($RT::WebSecureCookies ? 1 :0),
    );
    $r->headers_out->{'Set-Cookie'} = $cookie->as_string;
}

to add an 'expires' key:

if ( !$cookies{$cookiename} ) {
    my $cookie = new CGI::Cookie(
        -name  => $cookiename,
        -value => $session{_session_id},
        -path  => $RT::WebPath,
        -secure => ($RT::WebSecureCookies ? 1 :0),
        -expires =>  '+1M',
    );
    $r->headers_out->{'Set-Cookie'} = $cookie->as_string;
}

This particular setting makes the session good for one month. You can find out what time values are valid by looking at the CGI.pm documentation: http://search.cpan.org/~lds/CGI.pm-3.25/CGI.pm#CREATING_A_STANDARD_HTTP_HEADER%3A

Be sure to look at the following two articles to help clean up your old sessions (a good idea, evidently, whether or not you're planning on using this patch):

  • RT 3.8.8

For RT 3.8.8 version you need to edit the file $RTHOME/lib/RT/Interface/Web.pm. Look for the "sub SendSessionCookie" function and add the -expires key as stated above.

Tested on 3.8.7, file to modify is : /usr/share/request-tracker3.8/lib/RT/Interface/Web.pm (on a Debian/squeeze). -- jissouille

This was tested on RT 3.6.3, but I'm sure it would apply to most versions. -- JoeCasadonte I'm sure this should work for any version greater than 3.0.0 --RuslanZakirov