Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I 'm building a little members area site.

Some of the site is free for all, but then some areas are only for members.

I'm using CGI::Session and HTML::Template to structure my site.

I would like to offer my members the ability to view a page ....then if he comes across a "member only" section, then It wills end him to a page that has something like "Already a member? Log-in now, or sign up"

If the person is already a member, and decides to log-in, I would like it to go directly to the page he was previously trying to view.

How would I go about this? I really don't want to restructure my entire site to have this ability. If anyone has any module suggestions or referrences to add this ability, I would greatly appreciate it.

Thanks
  • Comment on Remembering the last page the user visited

Replies are listed 'Best First'.
Re: Remembering the last page the user visited
by CountZero (Bishop) on Mar 06, 2006 at 23:25 UTC
    The easiest way would be to either save the the page to be visited in a cookie or to use sessions which keep that page saved in a database. Either way you can recall the "last page visited" (but which was not visited for lack of previous log-in).

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Remembering the last page the user visited
by kwaping (Priest) on Mar 06, 2006 at 23:58 UTC
    If SSI is enabled on your machine, you might be able to do something like this:
    <input type="hidden" name="lastpage" value="<!--#echo var="REQUEST_URI +" -->">

    I don't have SSI enabled so I can't test the syntax, but I think that'll work. The only thing I'm not sure about is the nested double-quotes.

    ---
    It's all fine and dandy until someone has to look at the code.