Trait actix_web::middleware::session::RequestSession[][src]

pub trait RequestSession {
    fn session(&self) -> Session;
}

The helper trait to obtain your session data from a request.

use actix_web::middleware::session::RequestSession;
use actix_web::*;

fn index(mut req: HttpRequest) -> Result<&'static str> {
    // access session data
    if let Some(count) = req.session().get::<i32>("counter")? {
        req.session().set("counter", count + 1)?;
    } else {
        req.session().set("counter", 1)?;
    }

    Ok("Welcome!")
}

Required Methods

Get the session from the request

Implementors