Results 1 to 20 of 34

Thread: I get only 1 of 4 cookies...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    Does that mean that you have to add something to your request? Or do you mean that you get too few cookies but expect it to work?

  2. #2
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    I need all four cookies it won't work with just one.

  3. #3
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...


  4. #4
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    Can you tell me how to check because allCookies() is protected and I don't want to subclass the whole class....

  5. #5
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    I'd go or the cookiesForUrl function.

  6. #6
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    I inserted
    Qt Code:
    1. QList<QNetworkCookie> jar=manager->cookieJar()->cookiesForUrl(QUrl(line));
    To copy to clipboard, switch view to plain text mode 
    on line 7
    and in debug mode jar stayed empty until the program ended.

  7. #7
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    How does the original URL look? Do you try to login here, or do you try to access some location where you already are logged in? If so, how did you originally log in there?

    You say that you reach the login/wrong password page, and that seems reasonable to me if you don't have any cookies...

  8. #8
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    Here is the deal:
    1) I send the user and password to the server that the original http://abv.bg 's form will send the data.
    2) The server returnes me "HTTP 302 Moved temporarily" and a link like:
    http://mailXX.abv.bg/servlet/plogin?s=hewirhwekrjhwekjrhw.passportX" wher re X's are random nubers.
    3) When I go to that page I get the same HTTP 302 Moved temprarily message but with differtent mailXX.
    4) I go there and this page gives me 4 cookies: example:
    Qt Code:
    1. Set-Cookie: JSESSIONID=4D6B05D58928843F51D03F6D85ED5F40; Path=/app\r\n
    2. SET-COOKIE: _key=7710db16cea77c8152a557a0ab0469cc; Path=/app; HTTPOnly\r\n
    3. Set-Cookie: uhost=mail33.abv.bg; Domain=.abv.bg; Path=/\r\n
    4. Set-Cookie: usid=4D6B05D58928843F51D03F6D85ED5F40; Domain=.abv.bg; Path=/\r\n
    To copy to clipboard, switch view to plain text mode 
    and redirects me to "http://mailXX.abv.bg/app/j/home.jsp" whre the XX are from the last page . ( the page that gave me the cookies)
    This is what I need. I used WGET to deal with the cookies and everything is ok, but my program reached version 1.00 and I want to remove it because it's stupid for the windows version to come with a hidden wget.exe in the same folder.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: I get only 1 of 4 cookies...

    In general I'd say that what the server returns you could be a bit invalid. From what I understand (I could be wrong though) there should only be one header of each type therefore you only get one set-cookie header that contains all cookies that are to be set separated by semicolons.

    QNetworkReply::header() should return you a QVariant when passed QNetworkRequest::SetCookieHeader. This variant is really QList<QNetworkCookie>. When you get hold of it, you can list its contents to check out what cookies you are set. Then you can store them in your cookie-jar.

    Be sure to cast the variant to a proper type or else you will get an empty list like you do now.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    I tried that on line 12 and 14 on the first post and "list" is empty.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: I get only 1 of 4 cookies...

    Quote Originally Posted by cherva View Post
    I tried that on line 12 and 14 on the first post and "list" is empty.
    Read again my last sentence and see what QVariant::toList() returns.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    Qt Code:
    1. QVariant cookies=reply->header(QNetworkRequest::SetCookieHeader);
    2. QList<QVariant> list = cookies.toList();
    To copy to clipboard, switch view to plain text mode 
    Makes cookies = QList<QNetworkCookie> and list = 0 items

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.