Skip to content

Commit

Permalink
Merge pull request #4 from noppoMan/fix-no-session
Browse files Browse the repository at this point in the history
Enable to access context.session even cookie is not sent from client
  • Loading branch information
noppoMan authored Jul 6, 2017
2 parents b95d13e + 4432888 commit 49bbbd6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Sources/HexavilleFramework/Session/SessionMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public final class SessionMiddleware: Middleware {

guard let cookie = request.cookies.filter({ $0.name == cookieAttribute.key }).first else {
let id = Session.generateId()
context.session = Session(id: id, store: store, ttl: cookieAttribute.expiration)
context.responseHeaders["Set-Cookie"] = generateCookie(withSessionId: id).description
return .next(request)
}
Expand Down

0 comments on commit 49bbbd6

Please sign in to comment.