Results 1 to 5 of 5

Thread: "inject" cookie to external browser

  1. #1
    Join Date
    Jan 2012
    Posts
    29
    Thanks
    7

    Default "inject" cookie to external browser

    Hi, with my app the user gets authenticated to a website where he gets cookies for the session. Then I would need the user to navigate through an external browser (i.e. firefox) and appear as already authenticated. So I basically need to pass the cookies from my cookiejar to firefox.

    Does anyone have experience with this? I know it is more related to firefox but I wonder if there is a hint from the experts here as well.

    Thanks,
    Jan

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

    Default Re: "inject" cookie to external browser

    I think it all depends whether firefox is already active or not. If not, you can access its cookie database (it's in sqlite format) and inject the cookie there. If firefox is already active then... well... you're probably out of luck. What is the point of what you are trying to do? Can't you do it without the external browser or by forwarding auth information in the url passed to the browser?
    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.


  3. #3
    Join Date
    Jan 2012
    Posts
    29
    Thanks
    7

    Default Re: "inject" cookie to external browser

    Hi wysota,

    I see, so your thought is that the database is read only at startup.. this may be a problem also because it seems firefox -new-instance seems cannot be created, at least by default (I have to double check).

    My app is actually currently using a QWebView object in order to let the user browse the content, however i really think that using the user's default and preferred browser would be the best if I could still keep and so automate the initial authentication steps in my app..

    Authentication could be made with a properly formatted URL of course, this is the way I would go in case there are no other options. The problem with this solution is that either I open a firefox new tab/windows at the very beginning of my app to authenticate the user or I always go for authentication process (not fast at all) every time the user need to browse some content. The former would mean there will always be a firefox session open with my app and if closed nothing will work anymore, not good, the latter would solve this issue and results more elegant but much more slow.. not the best...

    So this is why I think the top would be "silently" authenticate the user using a QWebPage and collecting all the cookies for the session, as I do now, and then pass this information somehow to the external browser.. Just realized I mentioned firefox but could be any other browser... even more complicated... :-(

    Thanks,
    Jan


    Added after 5 minutes:


    this may be a problem also because it seems firefox -new-instance seems cannot be created, at least by default (I have to double check).
    Just verified -new-instance is intended to work with a profile different than the current one...
    Last edited by dotjan; 15th November 2012 at 09:08.

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

    Default Re: "inject" cookie to external browser

    I don't think you can find a general solution to your problem. Injecting a cookie in popular browsers shouldn't be that much of a problem provided they are not running but one can always have a custom browser or the browser might already be running. Going with the QWebView approach is probably the easiest thing to do.
    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.


  5. The following user says thank you to wysota for this useful post:

    dotjan (15th November 2012)

  6. #5
    Join Date
    Jan 2012
    Posts
    29
    Thanks
    7

    Default Re: "inject" cookie to external browser

    yes I think you are right wysota. Have also a discussion with firefox dev and accessing sqlite db while firefox is running will cause issue and it actually ties me to it which could change in the future. And anyway it also true I will tie myself to firefox only which is not what I want.

    i will have to make my QWebView more similar to a browser, actually not really evertything.

    Thanks,
    Jan

Similar Threads

  1. Replies: 4
    Last Post: 15th July 2012, 02:41
  2. defining a secondary "searching folder" for external codes
    By szisziszilvi in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2011, 11:04
  3. Replies: 4
    Last Post: 5th January 2011, 15:51
  4. The PostgreSQL plugin is not loaded in "SQL Browser" example
    By Scratch in forum Installation and Deployment
    Replies: 1
    Last Post: 18th November 2008, 01:30
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.