Jump to content

double redirect with GET parameters


valan
 Share

Recommended Posts

I have the following scenario:

User receives email with link that has GET parameters (smth like http://mysite.com/mailbox/?message=1234).

Since user doesn't have access to this page (e.g. not logged in), first of all, system should redirect him to login page (e.g. to http://mysite.com/login/) and only after succesful login - redirect user to initial link.

First redirect can be configured in PW template access settings. However, as far as I understand, optional {id} tag will only be replaced with page ID (e.g.  http://mysite.com/mailbox/), but GET parameters (e.g. message=1234) will be lost. So, how to receive these GET parameters (message=1234) in http://mysite.com/login/ ?

Link to comment
Share on other sites

You can code the redirect yourself instead setting it in the templates access settings:

if (!$user->isLoggedIn()) {
  $session->redirect($pages->get('/login/')->url . '?message=' . (int)$input->get->message);
}

Or store the message ID in a session variable and read it out on your login page.

(Code not tested... :))

  • Like 3
Link to comment
Share on other sites

Wanze, thanks! Yes, own coding is solution. I just think that this is a typical scenario. Therefore it is better to have it "in PW template settings", e.g. adding {url} tag (by analogy to available {id} tag) which may be replaced by original URL string value.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...