diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py index 31a56a4..8379691 100644 --- a/IPython/frontend/html/notebook/handlers.py +++ b/IPython/frontend/html/notebook/handlers.py @@ -507,6 +507,12 @@ class AuthenticatedZMQStreamHandler(ZMQStreamHandler, IPythonHandler): # under Python 2.x for some reason msg = msg.encode('utf8', 'replace') try: + bsession, msg = msg.split(':', 1) + self.session.session = bsession.decode('ascii') + except Exception: + logging.error("No bsession!", exc_info=True) + pass + try: self.request._cookies = Cookie.SimpleCookie(msg) except: self.log.warn("couldn't parse cookie string: %s",msg, exc_info=True) @@ -528,7 +534,7 @@ class ZMQChannelHandler(AuthenticatedZMQStreamHandler): def create_stream(self): km = self.kernel_manager meth = getattr(km, 'connect_%s' % self.channel) - self.zmq_stream = meth(self.kernel_id) + self.zmq_stream = meth(self.kernel_id, identity=self.session.bsession) def initialize(self, *args, **kwargs): self.zmq_stream = None diff --git a/IPython/frontend/html/notebook/static/js/kernel.js b/IPython/frontend/html/notebook/static/js/kernel.js index ee304db..78741c7 100644 --- a/IPython/frontend/html/notebook/static/js/kernel.js +++ b/IPython/frontend/html/notebook/static/js/kernel.js @@ -129,7 +129,7 @@ var IPython = (function (IPython) { this.shell_channel = new this.WebSocket(ws_url + "/shell"); this.iopub_channel = new this.WebSocket(ws_url + "/iopub"); send_cookie = function(){ - this.send(document.cookie); + this.send(that.session_id + ':' + document.cookie); }; var already_called_onclose = false; // only alert once var ws_closed_early = function(evt){