0

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.

NeedForS
  • 33
  • 4
  • QWebView is pretty much already a simple web browser. And normally web browsers do not logout users from web sites. – divanov Oct 26 '12 at 15:08
  • This is implemented on the server side, not on the client. In other words, QWebView has nothing to do with it. – Nikos C. Oct 26 '12 at 15:54
  • If you close the webView, and then open a new webView on the same site, then the session will be closed. How can this be achieved without closing webView? – NeedForS Oct 27 '12 at 10:38
  • @NeedForS this depends how session is implemented. For most of server-side sessions this won't happen until session timeout will be reached. For most of cookie-based ones this won't happen too until cookies are expired. – divanov Nov 02 '12 at 15:34

2 Answers2

1

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

Blazemonger
  • 90,923
  • 26
  • 142
  • 180
kingi
  • 26
  • 1
  • 2
0

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.

Cameron Tinker
  • 9,634
  • 10
  • 46
  • 85