Author | Topic: oHtml:SetCookie() and JScript document.cookie incompatability | |
---|---|---|
Vladimir Iahnenco | oHtml:SetCookie() and JScript document.cookie incompatability on Thu, 02 Sep 2004 23:00:53 -0400 Hello Everybody, Found an issue with cookies. I parsed oHtml:GetCookie() string with some cookies on my machine (some init values) Cookie1 - Value1 Cookie2 - Value2 Cookie3 - Value3 I wanted to change Cookie2 value so I did oHtml:setCookie(Cookie2, Value4) Parsed and got Cookie1 - Value1 Cookie2 - Value2 Cookie3 - Value3 Cookie2 - Value4 Changed again oHtml:setCookie(Cookie2, Value5) Parsed and got Cookie1 - Value1 Cookie2 - Value2 Cookie3 - Value3 Cookie2 - Value5 Changed again using oHtml:put("<script>document.cookie='"+Cookie2=Value6;"+<.script>) Parsed and got Cookie1 - Value1 Cookie2 - Value6 Cookie3 - Value3 Cookie2 - Value5 Have fun with cookies -- Regards, Vladimir | |
Phil Ide | Re: oHtml:SetCookie() and JScript document.cookie incompatability on Fri, 03 Sep 2004 10:46:34 +0100 Vladimir, > Have fun with cookies ROFL - I bypass :setCookie altogether: FUNCTION SetCookie( oHtml, cCookie, cValue, cPath, cExpires ) local cRet := 'Set-Cookie: '+cCookie+'='+cValue+' ; PATH='+; cPath+' ; EXPIRES='+cExpires if IsMemberVar( oHtml, 'cCookie' ) if !Empty(oHtml:cCookie) oHtml:cCookie += CRLF endif oHtml:cCookie += cRet else oHtml:setCookie(cCookie,cValue,Date()+1,cPath) endif return (cRet) The 'else' clause was put there in case Alaska made oHtml:cCookie protected in future releases - something I no longer have to worry about Regards, Phil Ide *************************************** * Xbase++ FAQ, Libraries and Sources: * * goto: http://www.idep.org.uk/xbase * *************************************** Press any key to continue, press any other key to abort... | |
Vladimir Iahnenco | Re: oHtml:SetCookie() and JScript document.cookie incompatability on Fri, 03 Sep 2004 10:26:20 -0400 Phil, What is cExpires date string format? -- Regards, Vladimir "Phil Ide" <phil@idep.org.uk> wrote in message news:1tgcwe9sp9id0$.dlg@idep.org.uk... > Vladimir, > > > Have fun with cookies > > ROFL - I bypass :setCookie altogether: > > FUNCTION SetCookie( oHtml, cCookie, cValue, cPath, cExpires ) > local cRet := 'Set-Cookie: '+cCookie+'='+cValue+' ; PATH='+; > cPath+' ; EXPIRES='+cExpires > > if IsMemberVar( oHtml, 'cCookie' ) > if !Empty(oHtml:cCookie) > oHtml:cCookie += CRLF > endif > oHtml:cCookie += cRet > else > oHtml:setCookie(cCookie,cValue,Date()+1,cPath) > endif > return (cRet) > > > The 'else' clause was put there in case Alaska made oHtml:cCookie protected > in future releases - something I no longer have to worry about > > Regards, > -- > Phil Ide > > *************************************** > * Xbase++ FAQ, Libraries and Sources: * > * goto: http://www.idep.org.uk/xbase * > *************************************** > > Press any key to continue, press any other key to abort... | |
Phil Ide | Re: oHtml:SetCookie() and JScript document.cookie incompatability on Fri, 03 Sep 2004 17:24:37 +0100 Vladimir, > What is cExpires date string format? Sorry, it is a date in CGI format: Function CGIDate( dDate ) local dDate := Date() local cRet cRet := Left(cDow(dDate),3)+', ' cRet += StrZero(Day(dDate),2)+; '-'+; Left(CMonth(dDate),3)+; '-'+; LTrim(Str(Year(dDate)))+' ' cRet += '12:00:00 GMT' return (cRet) Regards, Phil Ide *************************************** * Xbase++ FAQ, Libraries and Sources: * * goto: http://www.idep.org.uk/xbase * *************************************** Veni, vidi, velcro: I came, I saw, I stuck around. | |
Vladimir Iahnenco | Re: oHtml:SetCookie() and JScript document.cookie incompatability on Fri, 03 Sep 2004 11:25:04 -0400 And what starnge, I didn't find iVar cCookie in the debugger, but it works. Thank you very very much Phil. One issue left unkown for me - if I escape(cValue) in the JS, does any unescape(cValue) required if I get it from oHtml. Will try to play later on. -- Regards, Vladimir "Phil Ide" <phil@idep.org.uk> wrote in message news:1tgcwe9sp9id0$.dlg@idep.org.uk... > Vladimir, > > > Have fun with cookies > > ROFL - I bypass :setCookie altogether: > > FUNCTION SetCookie( oHtml, cCookie, cValue, cPath, cExpires ) > local cRet := 'Set-Cookie: '+cCookie+'='+cValue+' ; PATH='+; > cPath+' ; EXPIRES='+cExpires > > if IsMemberVar( oHtml, 'cCookie' ) > if !Empty(oHtml:cCookie) > oHtml:cCookie += CRLF > endif > oHtml:cCookie += cRet > else > oHtml:setCookie(cCookie,cValue,Date()+1,cPath) > endif > return (cRet) > > > The 'else' clause was put there in case Alaska made oHtml:cCookie protected > in future releases - something I no longer have to worry about > > Regards, > -- > Phil Ide > > *************************************** > * Xbase++ FAQ, Libraries and Sources: * > * goto: http://www.idep.org.uk/xbase * > *************************************** > > Press any key to continue, press any other key to abort... |