title: How to persist SignalR connection ID
body: <p>I’m trying to build a chat apps whereby users id are represented by their auto generated signalR connection id. On page refresh, the connection id changes when a new connection is instantiated. Is there a way to persist the state of the connection id of a user until the browser session is ended (i.e until he ends his session on client).</p>
  
  <p>Any guide or documentation? It really would help.</p>
  
  <p>i am new in signalr. so trying to know many things searching Google. from this url i got a similar snippet <a href="http://kevgriffin.com/maintaining-signalr-connectionids-across-page-instances/" rel="nofollow">http://kevgriffin.com/maintaining-signalr-connectionids-across-page-instances/</a></p>
  
  <p>they are saying it is possible. the problem is signalr often create a new connection id if we referesh the page. i want to prevent this but how.......</p>
  
  <p>this code snippet.</p>
  
  <pre><code>public class MyConnectionFactory : IConnectionIdFactory
      {
          public string CreateConnectionId(IRequest request)
          {
              if (request.Cookies["srconnectionid"] != null)
              {
                  return request.Cookies["srconnectionid"];
              }
  
              return Guid.NewGuid().ToString();
          }
      }
  
  $.connection.hub.start().done(function () {
          alert("Connected!");
          var myClientId = $.connection.hub.id;
          setCookie("srconnectionid", myClientId);
      });
  
      function setCookie(cName, value, exdays) {
          var exdate = new Date();
          exdate.setDate(exdate.getDate() + exdays);
          var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
          document.cookie = cName + "=" + c_value;
      }
  </code></pre>
  
  <p>my doubt is does it work in all signalr version? if not then how to handle it in new version specially for not generate a new connection id if page gets refreshed. looking for suggestion. </p>
  
  <p>if we work with Persistent connection class instead of hub then what happen.....in this case connection id will persist if we refresh the page at client side? please guide.
  thanks</p>