I've created this bit of code:
Which works, but each time I make a request I get a new sessionID.. How Do I maintain a session, thus keeping the same sessionID?
Okay, I've come up with a more elaborate way that I'd think would keep the same connection thus keeping the same session id, but still no luck. Also the timing is buggy. Apologize for the sloppy code, I haven't cleaned it up yet.
*Edit cleaned up second example a little more.
For a=1 To 10 Print GetHTTP("www.yahoo.com") Next Function GetHTTP:String(sURL:String) Local TXT:String="" Local In:tStream=ReadStream("HTTP::" + sURL) If Not In RuntimeError "Failed to open " + sURl While Not Eof(In) TXT=TXT + ReadLine(In) Wend CloseStream In Return TXT End Function
Which works, but each time I make a request I get a new sessionID.. How Do I maintain a session, thus keeping the same sessionID?
Okay, I've come up with a more elaborate way that I'd think would keep the same connection thus keeping the same session id, but still no luck. Also the timing is buggy. Apologize for the sloppy code, I haven't cleaned it up yet.
Local sUrl:String="www.blitzbasic.com" Local sPage:String="faq/faq.php" Local TXT:String Local A:Int Local WebSock:tSocket=CreateTCPSocket() ConnectSocket(WebSock,HostIp(sURL),80) While Not SocketConnected(WebSock) ' should put timeout in here then Wend Print "We Connected,now write out request." Local WebStream:tSocketStream=CreateSocketStream(WebSock,False) Print "Write out first request" WriteLine WebStream,"GET /" + sPage +" HTTP/1.1" WriteLine WebStream,"Host: " + surl WriteLine WebStream,"User-Agent: BlitzBrowser" WriteLine WebStream,"Accept: */*" WriteLine WebStream,"" FlushStream(WebStream) TXT="Start" A=MilliSecs()+10 While Len(TXT)>0 Or A>MilliSecs() TXT=ReadLine(WebStream) Print TXT Wend '========================================== Print "Write out second request" WriteLine WebStream,"GET /" + sPage +" HTTP/1.1" WriteLine WebStream,"Host: " + surl WriteLine WebStream,"User-Agent: BlitzBrowser" WriteLine WebStream,"Accept: */*" WriteLine WebStream,"" FlushStream(WebStream) TXT="Start" A=MilliSecs()+1000 While Len(TXT)>1 Or A>MilliSecs() TXT=ReadLine(WebStream) Print TXT Wend
*Edit cleaned up second example a little more.