[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] Re: Sessions and Best Practices


Whoops.  Forgot where replies to this list go.  Sorry Sean!

If someone clicks a link to app.pl?rm=edit and their session has
expired, is there a way to redirect them to rm=edit after they log in?
( as opposed to them seeing the default rm after logging in)

I'm just trying to wrap my head around all this stuff before doing any
coding.

Yep, but you need to store the "desired" run_mode in a hidden field on your login page. If you have something in pre-run that checks for "logged in", if a person isn't logged in and wants to get to rm edit, then you can just put a hidden field on your login page that is something like 'desired=edit'. Then, when you process the login, if the desired field is set, just redirect
to that run mode.  Make sense?

Sean

My 2 cents...

I used the method shown here:
http://cpan.uwinnipeg.ca/htdocs/CGI-Session/CookBook.html#members_area

So I don't have a separate "login" run mode. In setup(), I specify that I'll use a subroutine reference for the mode parameter. Then, my get_mode() method: - Checks to make sure that the mode parameter was specified. If not, I'm just starting, so I return the display login mode.
- Checks to see we're logged in.  If so, return the requested mode.
- Checks to see if we've submitted a login form. If not, the session has expired (not logged in but requested a mode), so the entire $self->query->Vars() hash is saved into hidden fields, the requested mode is saved as well, and an error message is set. Then the display login mode is returned. - If we've come this far, we've submitted the login form, so we process that. An error can be handled the same as an expired login, while a completion would result in the method returning the requested mode.

This actually takes place in my superclass that I build applications off of. I've added a call to a my_modify_mode() method before all of this, which allows a great deal of flexibility, but only when needed.

Hope this helps.

Jaclyn


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.