title: PHP session_start cookie doesn't save session id
body: <p>On my server i am starting a new session by calling a static class function.
  The problem is that the session id is not being saved in the session cookie, furthermore it seems that no session cookie is being saved at the client (eg. chrome doesn't display a cookie for the website).
  Printing out <code>$_COOKIE</code> results in <code>array(0) { }</code>. Same with <code>$_SESSION</code>.</p>
  
  <p>Here is the static class function which starts a new session:</p>
  
  <pre><code>&lt;?php
  class Session
  {
      private function __construct() { }
  
      public static function sec_session_start()
      {
          $session_name = 'sec_session_id';
          $secure = TRUE;                     // https only
          $httponly = true;                   // javascript can't access session id
  
          $cookieParams = session_get_cookie_params();
          session_set_cookie_params($cookieParams['lifetime'],
              '/',
              'www.example-domain.de',
              $secure,
              $httponly);
  
          session_name($session_name);
          session_start();               
          session_regenerate_id();       
      }
  }
  ?&gt;
  </code></pre>
  
  <p>And at the top of every page i am starting the session with</p>
  
  <pre><code>Session::sec_session_start();
  </code></pre>
  
  <p>For example when i am at the login page of my website and print out <code>var_dump($_COOKIE)</code> it says <code>array(0) { }</code> instead of <code>array(2) { ["PHPSESSID"]=&gt; string(26) "..." ["sec_session_id"]=&gt; string(26) "..." }</code>.</p>
  
  <p>The php ini looks as follows
  <a href="https://i.stack.imgur.com/vjg5L.png" rel="nofollow noreferrer">php ini</a></p>