Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkAccessManager: How to enable cookies / How to Facebook login?
Forum Updated to NodeBB v4.3 + New Features

QNetworkAccessManager: How to enable cookies / How to Facebook login?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    n1try
    wrote on last edited by
    #1

    Sometimes when you want to log in to a website you are told that yo have to enable cookies in your browser.
    I would like to know how to "enable" those cookies when doing the website login with QNetworkAccessManager:post().
    Any ideas?

    EDIT: To be more precise, I want to do a Facebook login by sending the parameters "email" and "pass" to Facebook's login.php, but always get told that I have to enable cookies in my browser's security settings.
    Am I right in thinking that by opening the startpage facebook.com some cookies are transmitted in the http header that later have to be sent back when calling the login form?

    EDIT2: So my actual question is, how does facebook login decide whether a user has cookies turned on or not. What actually makes my problem less Qt-Programming related, but maybe anyone still knows a solution.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Facebook knows you are not returning its cookies simply because you do not return them.

      QNetworkAccessManager uses a QNetworkCookieJar to store cookies. If cookies are in the jar for the site they will be sent automatically, you do not need to do anything special. The default cookie jar implementation has no persistent storage so cookies are only good for the lifetime of the QNetworkAccessManager and QNetworkCookieJar. If you create a new QNetworkAccessManager for each request then you will never have cookies to return.

      See QNetworkAccessManager::setCookieJar() and subclass QNetworkCookieJar if you want to implement some form of cookie persistence.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        n1try
        wrote on last edited by
        #3

        Thank you. It is as you said.
        I just had to use the same nam for opening the startpage and the login page after having assigned a CookieJar before. Works fine now.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved