Web Connection
How to show messages when using response.redirect
Gravatar is a globally recognized avatar based on your email address. How to show messages when using response.redirect
  Phil Sherwood
  All
  Jun 20, 2017 @ 02:28pm

I've got a forgot password function that needs to pass a message back to the login page. I set a variable with the message like so:

pcErrorMessage = "An email has been sent to the email associated with user: " + ; ALLTRIM(lcUser) + " if a user with that username was found."

sent to the _login.wcs script whether the given user was found or not.

If I bring up the _login.wcs page by doing a response.expandscript() it brings up the message fine. The only problem is that the URL is still the forgotpw page and if they attempt to login now, the forgotpw logic runs since that's the url.

If I do a

SESSION.SetSessionVar('ErrorMsg', pcErrorMessage)

after setting the pcErrorMessage above and then do a response.redirect('login.or'), the login page comes up but no message. I have the login method checking for the session variable and setting pcErrorMessage to the value at the top.

I believe the session is getting trashed because of the redirect since the headers aren't rewritten.

What is the correct way to handle this?

Any help would be appreciated. Thanks!

-Phil

Gravatar is a globally recognized avatar based on your email address. re: How to show messages when using response.redirect
  Rick Strahl
  Phil Sherwood
  Jun 20, 2017 @ 03:23pm

Session should work since it's a fox table. Once written you can reaccess it. A redirect doesn't kill your cookie. There's gotta be something else happening when you're reading the value back out.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: How to show messages when using response.redirect
  Phil Sherwood
  Rick Strahl
  Jun 21, 2017 @ 08:49am

Found it and it was a stupid typo.

My _login.wcs had this at the top:

if vartype(pcUserName) !="C"  
   pcErrorMessage =""  
endif  

Notice the vartype was checking pcUserName instead of pcErrorMessage. Doh!
Never thought to look at the script.

-Phil

Gravatar is a globally recognized avatar based on your email address. re: How to show messages when using response.redirect
  Rick Strahl
  Phil Sherwood
  Jun 21, 2017 @ 03:38pm

Yeah I think that was a bug in the project template for a previous release. That's been addressed in 6.10 and later I think, but of course that won't help if you created the template with an older version 😃

+++ Rick ---

© 1996-2024