title: How can I share sessions between actix-session and a PHP application when using Redis as session storage?
body: <p>I want to switch my PHP website using Redis as session storage to actix-web. The only problem I've encountered is sharing sessions between my subdomains. I have many services and only some of them will get switched to Rust.</p>
  
  <p>A <a href="https://docs.rs/actix-session/0.1.1/actix_session/" rel="nofollow noreferrer">crate already exists for sessions</a>:</p>
  
  <pre class="lang-rust prettyprint-override"><code>use actix_session::{CookieSession, Session};
  use actix_web::{web, App, Error, HttpResponse, HttpServer};
  
  fn index(session: Session) -&gt; Result&lt;&amp;'static str, Error&gt; {
      // access session data
      if let Some(count) = session.get::&lt;i32&gt;("counter")? {
          println!("SESSION value: {}", count);
          session.set("counter", count + 1)?;
      } else {
          session.set("counter", 1)?;
      }
  
      Ok("Welcome!")
  }
  
  fn main() -&gt; std::io::Result&lt;()&gt; {
      HttpServer::new(|| {
          App::new()
              .wrap(
                  CookieSession::signed(&amp;[0; 32]) // &lt;- create cookie based session middleware
                      .secure(false),
              )
              .service(web::resource("/").to(|| HttpResponse::Ok()))
      })
      .bind("127.0.0.1:59880")?
      .run()
  }
  </code></pre>
  
  <p>My goal is to be able to read a Rust session from my PHP scripts.</p>
  
  <p>Here's what I've tried:</p>
  
  <pre class="lang-php prettyprint-override"><code>session_name('RustAndPHP'); // I don't have any idea to name the sessions in Rust
  
  session_set_cookie_params(0,"/",".mydomainname.com",FALSE,FALSE);
  setcookie(session_name(), session_id(),0,"/","mydomainname.com");
  session_start();
  </code></pre>
  
  <p>And finally, I changed the default cookie:</p>
  
  <pre class="lang-php prettyprint-override"><code>setcookie( "mysession", "",1,"/" );
  setcookie( "PHPSESSID", "",1,"/" );
  </code></pre>
  
  <p>I have no idea of the session format used in Rust and how to be able to share it with PHP.</p>