Repository: ipython/ipython

Issue:
Can't connect to 2 HTTPS notebook servers on the same host
Just discoverd that one can't  connect to two notebooks server at the same time if they are (both?) over https.
Login to another notebook server make the cookie invalid for the first server, not actually preventing you from executing code
but preventing you from dooing stuff like saving.

<del>
Speeking of saving, could we reopen #883 ? 
The `saving failed` message in again pretty brief and not very visible, having the pop up back would be cool.
</del>


<del>
Can I add "listening on http also and redirecting to https dashboard if notebook is password protected" in the wishlist  ?
</del>

(not expecting answer until pycon is over of course...)

Thanks.



Discussion:
Can you edit this issue to focus on one thing?  I would post the comment on #883 in that issue.  Also, the last question is not clear what you mean.

Yes, the  second and third paragraphs where to ask if I should open another issues, i might not have been very clear sorry about that.

punting this cookie issue to 0.14.


Resolving patch:
diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py
--- a/IPython/frontend/html/notebook/handlers.py
+++ b/IPython/frontend/html/notebook/handlers.py
@@ -146,13 +146,13 @@ class AuthenticatedHandler(RequestHandler):
     """A RequestHandler with an authenticated user."""
 
     def get_current_user(self):
-        user_id = self.get_secure_cookie("username")
+        user_id = self.get_secure_cookie(self.settings['cookie_name'])
         # For now the user_id should not return empty, but it could eventually
         if user_id == '':
             user_id = 'anonymous'
         if user_id is None:
             # prevent extra Invalid cookie sig warnings:
-            self.clear_cookie('username')
+            self.clear_cookie(self.settings['cookie_name'])
             if not self.application.password and not self.application.read_only:
                 user_id = 'anonymous'
         return user_id
@@ -242,7 +242,7 @@ def post(self):
         pwd = self.get_argument('password', default=u'')
         if self.application.password:
             if passwd_check(self.application.password, pwd):
-                self.set_secure_cookie('username', str(uuid.uuid4()))
+                self.set_secure_cookie(self.settings['cookie_name'], str(uuid.uuid4()))
             else:
                 self._render(message={'error': 'Invalid password'})
                 return
@@ -253,7 +253,7 @@ def post(self):
 class LogoutHandler(AuthenticatedHandler):
 
     def get(self):
-        self.clear_cookie('username')
+        self.clear_cookie(self.settings['cookie_name'])
         if self.login_available:
             message = {'info': 'Successfully logged out.'}
         else:
@@ -427,7 +427,7 @@ def open(self, kernel_id):
         self.on_message = self.on_first_message
 
     def get_current_user(self):
-        user_id = self.get_secure_cookie("username")
+        user_id = self.get_secure_cookie(self.settings['cookie_name'])
         if user_id == '' or (user_id is None and not self.application.password):
             user_id = 'anonymous'
         return user_id
diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py
--- a/IPython/frontend/html/notebook/notebookapp.py
+++ b/IPython/frontend/html/notebook/notebookapp.py
@@ -28,6 +28,7 @@
 import sys
 import threading
 import time
+import uuid
 import webbrowser
 
 # Third party
@@ -164,6 +165,7 @@ def __init__(self, ipython_app, kernel_manager, notebook_manager,
             static_handler_class = FileFindHandler,
             cookie_secret=os.urandom(1024),
             login_url="%s/login"%(base_project_url.rstrip('/')),
+            cookie_name='username-%s' % uuid.uuid4(),
         )
 
         # allow custom overrides for the tornado web app.


Test patch: