Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Copy over cookies after each completed web request
Browse files Browse the repository at this point in the history
for authentication!
  • Loading branch information
joemasilotti committed Nov 7, 2023
1 parent ee81553 commit f753dff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/TurboNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation
import SafariServices
import Turbo
import UIKit
import WebKit

public class TurboNavigator: TurboNavigationHierarchyControllerDelegate {
public unowned var delegate: TurboNavigatorDelegate
Expand Down Expand Up @@ -105,7 +106,11 @@ extension TurboNavigator: SessionDelegate {
}

public func sessionDidFinishRequest(_ session: Session) {
// Do we need to expose this if we save cookies?
guard let url = session.activeVisitable?.visitableURL else { return }

WKWebsiteDataStore.default().httpCookieStore.getAllCookies { cookies in
HTTPCookieStorage.shared.setCookies(cookies, for: url, mainDocumentURL: url)
}
}

public func sessionDidLoadWebView(_ session: Session) {
Expand Down

0 comments on commit f753dff

Please sign in to comment.