Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 1dd831e

Browse files
committed
add cookie example
1 parent 31bce35 commit 1dd831e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

SocketTesterARC/ViewController.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ - (void) viewDidLoad
2828
// if you want to use https instead of http
2929
// socketIO.useSecure = YES;
3030

31+
// pass cookie(s) to handshake endpoint (e.g. for auth)
32+
NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:
33+
@"localhost", NSHTTPCookieDomain,
34+
@"/", NSHTTPCookiePath,
35+
@"auth", NSHTTPCookieName,
36+
@"56cdea636acdf132", NSHTTPCookieValue,
37+
nil];
38+
NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:properties];
39+
NSArray *cookies = [NSArray arrayWithObjects:cookie, nil];
40+
41+
socketIO.cookies = cookies;
42+
3143
// connect to the socket.io server that is running locally at port 3000
3244
[socketIO connectToHost:@"localhost" onPort:3000];
3345
}

0 commit comments

Comments
 (0)