File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 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) {
281281 return base64id . generateId ( ) ;
282282} ;
283283
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+
284295/**
285296 * Handshakes a new client.
286297 *
@@ -317,11 +328,13 @@ Server.prototype.handshake = function (transportName, req) {
317328
318329 if ( false !== this . cookie ) {
319330 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 ;
325338 } ) ;
326339 }
327340
You can’t perform that action at this time.
0 commit comments