Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript for setting cookie is working incorrectly #14

Closed
cozzin opened this issue May 15, 2020 · 0 comments
Closed

Javascript for setting cookie is working incorrectly #14

cozzin opened this issue May 15, 2020 · 0 comments

Comments

@cozzin
Copy link
Contributor

cozzin commented May 15, 2020

Javascript for setting cookie is working incorrectly.
Script format for cookie should like this {name}={value}
Current script format is name={name}; value={value}

I made sample cookie for test in Example > ViewController > viewDidLoad()

    override func viewDidLoad() {
        super.viewDidLoad()

        let cookie = HTTPCookie(properties: [
            .domain: "github.com",
            .path: "/",
            .name: "[Test] Cookie",
            .value: "value!!"])!
        
        HTTPCookieStorage.shared.setCookie(cookie)

        setupWebView()
        webView.load(URLRequest(url: URL(string: urlString)!))
    }

And print out javascriptString

    var javaScriptString: String {
        if let values = (self.properties?
            .map { "\($0.key.rawValue)=\($0.value)" }
            .joined(separator: "; ")) {
            print("[TEST] script: \(values)")
            return values
        }

Console

[TEST] script: Discard=TRUE; Value=value!!; Path=/; Created=611202725; Name=[Test] Cookie; Domain=github.com

Safari debug
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants