Ferreteria/v0.5/stash: Difference between revisions

From Woozle Writes Code
Jump to navigation Jump to search
m (Woozle moved page Ferreteria/v0.5/message stash to Ferreteria/v0.5/session/stash: more accurate name)
m (Woozle moved page Ferreteria/v0.5/session/stash to Ferreteria/v0.5/stash without leaving a redirect: actually, it's not necessarily tied to the session; it's more about the user... but let's not try to nail that down too closely.)
(No difference)

Revision as of 19:41, 20 December 2022

Ferreteria 0.5: message stashing

About

Sometimes a process emits output right before a redirect needs to happen -- most commonly in response to a form submission (we do a redirect right after processing POST input in order to prevent accidental data resubmissions).

For this reason, the redirect system checks for output (which would/should not yet have been sent to the screen anyway), saves it in the user's browser via the stash cookie, and then does the redirect. The page object should always look for any stashed content to display, adding it at the top of any content it adds to the render. (This last part is currently not working, 2022-12-03.)

Design

Conceptually, there are two ways to "stash" data that needs to persist for a given browser session across plural http loads:

  • put the data in the browser cookie
  • put the data in the session record

The first one results in Ferreteria using two browser cookies (one for the Session ID, one for the stashed data) while the second uses only one (the Session ID loads the session data, including the stash).

Classes/Methods

  • The message text gets submitted to caPageContent->AddText(), which presumably adds it to the output buffer that the redirect process fetches from to toss over to the stash.
  • It looks like the stashed content is supposed to be retrieved by caPageContent->OnFigure()
  • storing/fetching the stash:
    • cookie method:
      • csAppCookie has the capability of reading/writing browser cookies
    • database method:
      • The ferret\login\session\card\cCalc class can read/write Session Stash data.

History

  • 2022-12-19 Given EU regulations around cookies, I'm thinking it might be a "selling point" to be able to say that Ferreteria uses exactly one cookie, without any caveats. The ability for apps to use cookie-stashing for their own purposes will still be there; we just won't use it for any core Ferreteria functionality (in this case, displaying a message generated by a redirected page).
  • 2022-12-18 Currently trying to track down which of the two designs I actually implemented. Tentatively, I may have done a mishmash of both, which could be why it isn't working right just at the moment...
    • The message is, in fact, stashed in the cookie under gmine-stash (the Session ID is in gmine-session).
    • It looks like the Session Calc class is trying to access it in the Session data, however... and it's not stored there. (The username is, though, for some reason.)