Struct fe_session::FeSessionConfig [] [src]

pub struct FeSessionConfig {
    // some fields omitted

Configuration object for the iron-session module.


use fe_session::FeSessionConfig;

let mut config = FeSessionConfig::new();

// Change the session timeout from the default of 15 minutes
// to 30 minutes and check for idle connections every 5 minutes.
config.set_session_timeout(30 * 60, 5 * 60);

// Change the session cookie from the default of "rsSession"
// to "mySession".

// Change the encryption code for the session cookie from a
// random value to a known value.
config.set_cookie_key(vec![0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]);


impl FeSessionConfig

fn new() -> FeSessionConfig

Creates a new instance with default values.

The default session time out is 15 minutes, which checks running every 2 minutes. The default session cookie is "feSession". And the key to sign/encrypt the cookie is randomly generated.

fn set_session_timeout(&mut self, timeout: u64, frequency: u64)

Sets the amount of time a session can be idle before it's deleted.

The timeout must be greater than 0, it's default value is 900 seconds or 15 minutes. The frequency must be less than the session timeout.

Sets the name of the cookie to save the session ID in.

The value is trimmed and the result must have a length greater than 0. There are additional requirements that are not checked for, you may want to read RFC 2965 for what characters are valid in a cookie name.

Sets the key to encrypt/sign the session keys with.

This value should be not be shared with the public. If it is then people could in theory forge a session key and hijack someone's session. Since the session key is only valid for a user's session a random value is probably best as it should be virtually unhackable.

fn session_timeout(&self) -> u64

Returns the session timeout in seconds.

fn idle_frequency(&self) -> u64

Returns the how often idle sessions are checked for in seconds.

fn cookie_name(&self) -> &String

Returns the name of the cookie to save the session ID in.

fn cookie_key(&self) -> &[u8]

Returns the key to sign/encrypt the cookie with.

Trait Implementations

Derived Implementations

impl Clone for FeSessionConfig

fn clone(&self) -> FeSessionConfig

1.0.0fn clone_from(&mut self, source: &Self)

impl Debug for FeSessionConfig

fn fmt(&self, __arg_0: &mut Formatter) -> Result