Results 1 to 5 of 5

Thread: Qhttp, is it possible to set http sessions?

  1. #1
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    2

    Default Qhttp, is it possible to set http sessions?

    I just started developing with QT and I am building an applications which uses Qhttp requists to get data from a PHP server.

    I am able to use QT to set post variables and post those to the PHP pages on the server.

    I was wondering if it is possible to set (php) sessions, to enable me to send session information with the requests to the server (for authentication use)

    So is there a way to set http sessions in my application / qhttp request or an other easy way to send the session information to my PHP server?

    Thanks a lot in advance!

  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: Qhttp, is it possible to set http sessions?

    PHP sessions are implemented using cookies, so you only need to send a proper Cookie header in your request.

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

    joozt (20th August 2008)

  4. #3
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    2

    Default Re: Qhttp, is it possible to set http sessions?

    Thanks alot for the reply!

    So I just name the cookie like my session variable or do I need to add something else in the header?

    For example I want a Session called UserID, should I just use the following code?
    header.setValue("Cookie", "UserID="+UserID);

    This doesn't seem to work :S

  5. #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: Qhttp, is it possible to set http sessions?

    It depends. The cookie has to be set by the server using a SetCookie header. Then the client should always report the cookie back to the server in each request using Cookie header. Sessions (like in php) are kept on the server, the cookie is only used to identify the session so that no one else can use it (user id is too weak for that). If you just need the server to store some values in the client between requests, then use SetCookie on the server side and Cookie on the client side.

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

    joozt (20th August 2008)

  7. #5
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    2

    Default Re: Qhttp, is it possible to set http sessions?

    Quote Originally Posted by wysota View Post
    It depends. The cookie has to be set by the server using a SetCookie header. Then the client should always report the cookie back to the server in each request using Cookie header. Sessions (like in php) are kept on the server, the cookie is only used to identify the session so that no one else can use it (user id is too weak for that). If you just need the server to store some values in the client between requests, then use SetCookie on the server side and Cookie on the client side.
    Thanks alot this helps

    (I know UserID is to weak, I am also creating a unique session ID on the server witch the client also needs to send with every request and on top of that I am storing the clients IP, so even if someone "steals" the session It will be blokked).

    It has been a wile since I programmed in C++, I been more focused on PHP for the last 2 years .

    Anyway thanks alot for the replies this really helps.

Similar Threads

  1. From QHttp to QHttp over SSL
    By Nyphel in forum Newbie
    Replies: 1
    Last Post: 3rd July 2007, 11:41
  2. QHttp & HTTP 1.1 Compression
    By bporter in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2007, 21:04
  3. how to use QHttp inside QThread in Qt3
    By alusuel in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2006, 12:19

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.