Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: Cookies are not being written

$
0
0
Re: Cookies are not being written
Web Connection 5.0
Re: Cookies are not being written
Feb. 28, 2013
02:41 am
3Q605SC7TShow this entire thread in new window
Gratar Image based on email address
From:Rick Strahl
To:Paul Mrozowski
Hi Paul,

Ok was able to repro and figured this out. It's a bit of mess, but I think the following will work:

* Remove the Response.ContentTypeHeader("NONE") from ExpandScript
* In wwScripting check the RenderAspScript method to:

************************************************************************FUNCTION RenderAspScript(lcTemplate as string)******************************************LOCAL loException, lcOutFile, lcFile, lcFXPFile, lcWCTFile, lcVFPCode,; lcFileName, lcFXPFile, lcWCTFile, llNeedToCompileIFEMPTY(THIS.cCompiledPath)this.cCompiledPath = JUSTPATH(lcTemplate) + "\"ELSEthis.cCompiledPath = ADDBS(THIS.cCompiledPath) ENDIFthis.cCurrentTemplate = lcTemplate*** Figure out our filenames to use lcFileName = JUSTFNAME(lcTemplate) lcFXPFile = FORCEEXT(THIS.cCompiledPath + lcFileName,"FXP")this.lError = .f.IFthis.lNoVersionCheck llNeedToCompile = .F.ELSE llNeedToCompile = .T.TRY*** This catches both fxp file not existing and being out of date*** Slightly more efficient than checking file, and the dates llNeedToCompile = FDATE(lcFxpFile,1) < FDATE(lcTemplate,1)CATCH llNeedToCompile = .t.ENDTRY*** Create and compile the file only if it doesn't exist*** or the timestamp of the FXP is older than the source file*** NOTE: Must use SYS(2000) instead of file so we don't look for files in the EXE!IF llNeedToCompileIF !this.ConvertAndCompileScript(lcTemplate)RETURNthis.AspScriptErrorResponse()ENDIFENDIFENDIF*** Output generated into this variablePRIVATE _Out _Out = ""*** Response object for the page object - writes to _OutPRIVATE Response LOCAL llResponseCreated && Add this variableIFISNULL(this.oResponse) Response = this.CreateResponse() llResponseCreated = .T.ELSE Response = this.oResponse llResponseCreated = .F.ENDIF loException = nullIFthis.lStopOnError*** fail and stop in the generated PRG fileDO (lcFXPFile) &&WITH lcOutputELSETRY*** Just execute the PRG FileDO (lcFxpFile) && WITH lcOutputCATCHTO loExceptionthis.lError = .t.this.cErrormsg = loException.Message*IF EMPTY(loException.LineContents) lcFile = FILE2VAR( FORCEEXT(lcFxPFile,"prg") )IF !EMPTY(lcFile)LOCAL lnCodeLines lnCodeLines = ALINES(laLines,lcFile)IF lnCodeLines > 0 AND loException.LineNo<= lnCodeLines loException.LineContents = ALLTRIM(laLines[loException.Lineno])ENDIFENDIF*ENDIFthis.oException = loExceptionENDTRYENDIFIFTHIS.lError _Out = this.AspScriptErrorResponse()*!* ELSE *!* _Out = this.oResponse.GetOutput()ENDIFIF (llResponseCreated) && change this IF from the class comparison beforeIFthis.lError Response.Status = "500 Server Error" Response.ContentType = "text/html"ENDIF _Out = Response.RenderHttpHeader() + _OutENDIFRETURN _OutENDFUNC

Specifically in the code the logic that dealt with how to figure out whether to render the header or not resulted in the original headers being thrown out and the old headers not getting written. With the code above this now works properly. The idea is if a Response object is passed in - leave all the headers previously set intact. Otherwise add them explicitly.

Let me know if this works.

+++ Rick ---


Sure.

Create this base process class and do a SET PROC to it.

DEFINECLASS mcgBaseProcess AS wwProcess cAuthenticationMode = "UserSecurity" lEnableSessionState = .T.* Make sure a user is authenticated before continuingFUNCTION OnProcessInit()IF !This.Authenticate() && If they're not, a login form should appearRETURNENDIFDODEFAULT()ENDFUNC* Will need to override default OnAuthenticateUser() method* to redirect to sign up page when the user account* has expired. FUNCTION OnAuthenticateUser(tcUserName, tcPassword, tcErrorMsg)This.oUserSecurity = CREATEOBJECT(This.cAuthenticationUserSecurityClass)IF !This.oUserSecurity.Authenticate(m.tcUserName, m.tcPassword)*** Set lcErrorMsg to pass back via REF parm tcErrorMsg = this.oUserSecurity.cErrorMsgRETURN .F.ELSE*ENDIFRETURN .T.ENDFUNCENDDEFINE

Then create a process class that subclasses from this.

Create a method in it like this:

FUNCTION Test2() Response.ExpandScript("Test2.wcs")ENDFUNC

And create a file for "Test2.wcs" and put pretty much anything in it.

Start the site and try to hit Test2. It redirects to the login. Log in, it should display the page. Go up to the address and hit enter to reload the page - it displays the login page again.

Can you give me a repro scenario here? What is the flow you're going through?

I can't recall why Response.ContentTypeHeader("NONE") is set to be honest... None prevents headers from rendering when the old wwHttpHeader() object is used (which it isn't in the new stuff with wwPageResponse).

I guess I need to see the failure scenario...

+++ Rick ---



Rick Strahl
West Wind Technologies


from Maui, Hawaii

Making waves on the Web


Viewing all articles
Browse latest Browse all 10393

Trending Articles