[Catalyst] setting/getting session data from within tests

A. Pagaltzis pagaltzis at gmx.de
Mon Jun 5 19:49:15 CEST 2006


* Daniel McBrearty <danielmcbrearty at gmail.com> [2006-06-05 19:05]:
> In my app, the user selects his language. Either language is
> stored in the session once selected, or you make him select
> anew every visit, and pass the value back and fore every
> request. My current implementation of engoi does this, but it's
> not pretty.

Just make language explicit in the URI, eg `example.net/en/` or
`example.net/de/` – and not optional, but required.

All state explicit in the URI. No state on the server.

The only page that wouldn’t use such a namespace and would still
need to be aware of state would be the `example.net/` homepage.
But even that responds with nothing but a redirect, which is easy
to test. (POST a lang pref, then check if the homepage redirects
to the just-selected lang namespace.)

> Same for any app where you have a members system with a
> persistent login.

That can be handled the same way: put the username in the URI as
a namespace, then require accesses to such a namespace to have
proper credentials.

All state explicit in the URI. No state on the server.

Again you only need to redirect from one place (the login page in
this case, which is even easier to test than the homepage).

For more on the subject of authentication, you may want to look
at <http://www.berenddeboer.net/rest/authentication.html>.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



More information about the Catalyst mailing list