File tree 1 file changed +18
-5
lines changed
1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,17 @@ Server.prototype.generateId = function (req) {
281
281
return base64id . generateId ( ) ;
282
282
} ;
283
283
284
+ /**
285
+ * Get additional cookies
286
+ * Overwrite this method to have additional serialized cookies sent in the handshake
287
+ *
288
+ * @param {Object } req object
289
+ * @returns {Array }
290
+ */
291
+ Server . prototype . getAdditionalCookies = function ( req ) {
292
+ return [ ] ;
293
+ } ;
294
+
284
295
/**
285
296
* Handshakes a new client.
286
297
*
@@ -317,11 +328,13 @@ Server.prototype.handshake = function (transportName, req) {
317
328
318
329
if ( false !== this . cookie ) {
319
330
transport . on ( 'headers' , function ( headers ) {
320
- headers [ 'Set-Cookie' ] = cookieMod . serialize ( self . cookie , id ,
321
- {
322
- path : self . cookiePath ,
323
- httpOnly : self . cookiePath ? self . cookieHttpOnly : false
324
- } ) ;
331
+ var cookies = self . getAdditionalCookies ( req ) || [ ] ;
332
+ cookies . push ( cookieMod . serialize ( self . cookie , id , {
333
+ path : self . cookiePath ,
334
+ httpOnly : self . cookiePath ? self . cookieHttpOnly : false
335
+ } ) ) ;
336
+
337
+ headers [ 'Set-Cookie' ] = cookies ;
325
338
} ) ;
326
339
}
327
340
You can’t perform that action at this time.
0 commit comments