Logout function in QWebView

625 Views Asked by At

I'm developing application in Qt 4.8.1. I trying to develope a simple web browser. I want to create function logout on site.

As I understand the required information is stored in cookies. In webView->page()->networkAccessManager()->cookieJar() I have not found clearing cookies. May be the session must be closed. Isn't? Help me to create the logout function.

2

There are 2 best solutions below

0
On BEST ANSWER

Maybe try delete the webpage object of the webview and instantiate a newPage object. and then webView->setPage(newPage);

0
On

You will need to simulate a logout using Javascript evaluation on the webPage->page()->mainFrame() object. For example, you could make a function like this to log out:

void Program::logout()
{
    webView->page()->mainFrame->evaluateJavaScript("websiteLogoutJavaScript();");
}

Of course, change the JS in the evaluate call to match the logout process. This method will depend on how to physically logout of the website. If it's a button, you could invoke a click event on the button. If it's a hyperlink that goes to a logout page, you could just navigate to the logout page. These are just some suggestions, but you will need to change the state of the DOM using JavaScript.