PyQt share session between two QWebView widgets
My app has two QWebViews in it. If a user navigates to a page in one of the WebViews and logs in then I'd like for that users login session to also work in the second WebView (so they don't have to login twice). Is there a way to do that?
I was playing around with QNetworkCookieJar and QNetworkAccessManager but didn't get anything to work.
I may have found an answer to this but it's in c++ and I don't know how to interpret it to python:
@jspeirs Code in your link deals with loading and saving cookies from/to file. If you don't need this, the only thing you should do is to set up the same
QWebViewobjects (or same cookie jar, but this is less efficient)
Ah ok I got it. I was over complicating it. Used this code to get the behavior I was looking for.
manager = QtNetwork.QNetworkAccessManager() webview = QtWebKitWidgets.QWebView() webpage = webview.page() webpage.setNetworkAccessManager(manager) webview.load(QUrl(url))
@Konstantin-Tokarev thanks, you helped me simplify my approach.