Within Tornado's tornado.websocket.WebSocketHandler
get_secure_cookie()
works however the clear_cookie()
function raises the following exception:
raise RuntimeError("Method not supported for Web Sockets")
RuntimeError: Method not supported for Web Sockets
Pretty obvious by the description there that it's not supported. Why is this the case?
It's not supported because once the connection is established, websockets are no longer HTTP and cannot send HTTP headers like Set-Cookie
. You'll have to send a message which your javascript can handle by changing the cookie (either setting it directly if it is script-accessible, or making a separate HTTP requests if it is HTTP-only).