Skip to content

Latest commit

 

History

History
13 lines (11 loc) · 653 Bytes

sessions.md

File metadata and controls

13 lines (11 loc) · 653 Bytes

Sakai Sessions

Sharing a session with a WKWebView

As Sakai uses cookie-based authentication instead of JWTs, you'll need to pass your cookies from the networking library (Alamofire) over to the WKWebView. This can be done by getting the Alamofire cookies and setting them on the httpCookieStore of the WKWebView.

Before loading the request, pass the SessionManager cookies to the httpCookieStore.

let cookies = Alamofire.SessionManager.default.session.configuration.httpCookieStorage?.cookies  ?? []
for cookie in cookies {
    webview.configuration.websiteDataStore.httpCookieStore.setCookie(cookie)
}
loadRequest(url: url)