title: Dealing with $_SESSION and Behat + mink + selenium
body: <p>In order to use the system i'm trying to test, you need to be an authenticated user. After you sign in, a $_SESSION variable is created, containing the user id and user_name, and while you're logged in. This session is always checked and if this session variable doesn't exist, the user is redirected to the login page. I'm able to sign in using behat, but as soon as it enters the system, i'm redirected back to the login page. If i comment the lines responsible for the $_SESSION verification, it works as expected. Do you guys know any way to sign in and keep the session? I've read a lot of solutions using laravel or symfony, but i'm not using any framework.</p>
  
  <p>Here's the feature code:</p>
  
  <pre><code>Feature:
      In order to use the system, the user needs a valid login first
  
  Scenario: Loading the log in page
      Given I am on "/login.php"
      Then I should see "Login"
  
  @javascript
  Scenario: Logging in with the right credentials 
      Given I am signed in
      And I am on "/students"
      And I wait 10 seconds
      Then I should see "logout"
  </code></pre>
  
  <p>And here is part of the mink context code:</p>
  
  <pre><code>/**
   * @Given /^(?:|I )am signed in$/
   */
  public function signIn()
  {
  
      session_start();
      $_SESSION['admin']["user_name"] = 'admin';
      $_SESSION['admin']["id"] = '1';
      $this-&gt;getSession()-&gt;getDriver()-&gt;setCookie(session_name(), session_id());
      session_commit();
  }
  </code></pre>