title: User by session ID in Devise authentication from background thread
body: <p>How to get an user or it's UserID by session ID (from cookie) when using Devise Authentication gem? I need to access this info from a background thread where <code>session</code> variable isn't accessible.</p>
  
  <p>Long explanation:</p>
  
  <p>I have two ports open on web server: one is for normal HTTP communication, other is for Web Sockets, for instant server-to-browser communication. Currently I initialize socket with</p>
  
  <pre><code>var UserID = &lt;%= current_user.id %&gt;
  </code></pre>
  
  <p>but consider this way to be insecure. Every authenticated user can replace user ID and receive messages intended for other user.</p>
  
  <p>So I think that SessionID stored in cookie is much harder to guess and it could be extracted by JavaScript in some way and passed through Web Socket during initialization.</p>
  
  <p>The task is to convert SessionID to UserID on server side.</p>
  
  <p>Is sessionID storage accessible as a whole through some Devise methods?</p>