I posted a code for reading a cookie from http header but still can't write a cookie. I can write anything accept "Cookie". When I write some value for "Cookie" field, after submiting the data, the "Cookie" field is clear. Please help me!
hi Sasa,
Did you try to parse multi set-cookies from one HTTP header? I want to get the cookie value from one response header, but only the first set-cookie can be read out. Thanks.
Forum posts: 26
Please help me!
RStringPool strP = aTrans.Session().StringPool();
RHTTPHeaders hdr = resp.GetHeaderCollection();
THTTPHdrFieldIter it = hdr.Fields();
TBuf<KMaxHeaderNameLen> fieldName16;
TBuf<KMaxHeaderValueLen> fieldVal16;
RStringF fieldCokie = strP.StringF(HTTP::ESetCookie,RHTTPSession::GetTable());
THTTPHdrVal fieldVal;
THTTPHdrVal cookie;
if (hdr.GetField(fieldCokie,0,fieldVal) == KErrNone){
RStringF basic = strP.StringF(HTTP::ECookie,RHTTPSession::GetTable());
RStringF realm = strP.StringF(HTTP::ECookieValue,RHTTPSession::GetTable());
if ((fieldVal.StrF() == basic) &&
(!hdr.GetParam(fieldCokie, realm, cookie))){
RStringF realmValStr = strP.StringF(cookie.StrF());
cookieValue.Copy(realmValStr.DesC());
}
}
It is always nice to help out people that need help.
http://www.vegaitsourcing.rs
http://www.codeplex.com/aspnetlibrary
Forum posts: 3
Forum posts: 26
I solved that and it worked fine for Symbian 7. I didn't try that code on 3rd edition but I think it should work.
Here is the code I used:
RStringF cookieField = iSess.StringPool().StringF(HTTP::ECookie,RHTTPSession::GetTable());
TBuf8<200> tempBuff;
tempBuff.Append(_L8("JSESSIONID="));
int sLen = strlen(status.sessionId);
tempBuff.Append((const TUint8*)status.sessionId, sLen);
aHeaders.SetRawFieldL(cookieField, (const TDesC8&)tempBuff, _L8(";"));
cookieField.Close();
}
Where "status.sessionId" is char* holding the value that I needed to set as cookie's value.
I hope this will help you.
Regards,
Sasa
It is always nice to help out people that need help.
http://www.vegaitsourcing.rs
http://www.codeplex.com/aspnetlibrary
Forum posts: 3
In the code used to read cookie variable Cookieval how is declared?
thanks again
Forum posts: 26
In the code used to read cookie variable Cookieval how is declared?
thanks again
Hi kelem,
cookieValue was member variable in that class declared like this:
...
TBuf8<KMaxHeaderValueLen> cookieValue;
If you find my answers helpful you can always thank me by clicking on "[Applaud]" link next to my answers
Regards,
Sasa
It is always nice to help out people that need help.
http://www.vegaitsourcing.rs
http://www.codeplex.com/aspnetlibrary
Forum posts: 6
Thnx dude
U make my day using this post
THis post is quite helpful to me
Regards
Smit
Forum posts: 26
Hi smitesh,
I'm glad you found it useful. I spent quite some time on that so I thought I will probably save some else's time by posting that code.
Cheers,
Sasa
It is always nice to help out people that need help.
http://www.vegaitsourcing.rs
http://www.codeplex.com/aspnetlibrary
Forum posts: 2
hi Sasa,
Did you try to parse multi set-cookies from one HTTP header? I want to get the cookie value from one response header, but only the first set-cookie can be read out. Thanks.
Landing