I want to store my websocket connection in cookies. I use $.cookie('ws', ws)
; in firebug ws looks like:
WebSocket {binaryType: "blob", extensions: "", protocol: "", onclose: function, onerror: null…}
URL: "wss://localhost:5432/"
binaryType: "blob"
bufferedAmount: 0
extensions: ""
onclose: function (m) {
onerror: null
onmessage: function (m) {
onopen: function () {
protocol: ""
readyState: 0
url: "wss://localhost:5432/"
__proto__: WebSocket
}
Problem:
When I get my websocket connection from cookies it looks like: [object WebSocket]
and I can't pull anything from it.
Question: How can I convert [object WebSocket]
to normal websocket object?
A cookie stores text , attempting to store an object will only store its string representation which is the useless character sequence " [object WebSocket]
".
Instead store the relevant (text) properties, read them back and reconstruct the object from scratch.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.