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!
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.
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
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.
Re: Qhttp, is it possible to set http sessions?
Quote:
Originally Posted by
wysota
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 :D
(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.