title: What is SessionID and how to "implement it" in SSO
body: <p>I have stumbled across a question &quot;Already answered&quot; in some places but I still have a doubt regarding <code>SESSION_ID</code></p>
  <p>Here is a very good <a href="https://stackoverflow.com/a/19929304/12696307">answer</a></p>
  <p>So basically the Idea is that I will have different domains/subdomains</p>
  <ol>
  <li><p>accounts.example.com (Equivalent to accounts.google.com)</p>
  </li>
  <li><p>example.com (Equivalent to google.com)</p>
  </li>
  <li><p>other-example.com (Equivalent to let's say: youtube.com)</p>
  </li>
  <li><p>other-v2-example.com (Equivalent to blogger.com (Blogspot))</p>
  </li>
  <li><p>If I visit example.com, other-example.com, other-v2-example.com and I don't have a session then I will be redirected to accounts.example.com</p>
  </li>
  <li><p>After signing on at accounts.example.com and try to access any of the other websites then I will have a session and will be able to access content for that specific user.</p>
  </li>
  </ol>
  <p><strong>The Question</strong></p>
  <p>Now, let's suppose I go to example.com, then I compare the credentials of the user against the ones in my DB.</p>
  <p>The credentials are correct.</p>
  <p>What should I do next?</p>
  <ol>
  <li><p>How do I generate the SESSION_ID? what should It contain? (Just a random string like a UUID?)</p>
  </li>
  <li><p>After the session_id has been generated, how will the API(s) use it to identify a specific user?</p>
  </li>
  <li><p>how would a middleware look like in a node.js app (express)?</p>
  </li>
  </ol>
  <p>3.1 Will it constantly need to query the database based on the SESSION_ID?</p>
  <ol start="4">
  <li>Should I create a new table in my db to store SESSION_ID that links the user with it? (From my point of view this is what will make it work but I want to make sure)</li>
  </ol>
  <p>I hope you can help me out with any resources, comments, suggestions, etc.</p>
  <p>THANK YOU Very much in advance.</p>