Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I am offering a link to my users that, if they are not logged in yet, is supposed to send them to the login page and then onwards to the target.

This is how I store the target page: <cms:set twirl_redirect="<cms:show k_page_link />#comments" scope='global' />

When I show this on the source page to test it, all is fine: it was stored and is shown.
<cms:show twirl_redirect /> shows: "https://www.and so on"

However, on the login page, which is supposed to redirect the user to it, it is gone.
<cms:show twirl_redirect /> shows ""

What am I doing wrong?
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
You are setting a variable on one page and trying to access it on another - this doesn't work in PHP as each page begins with a clean slate (i.e. has no notion of 'state').

You'll need to persist your variable explicitly in PHP 'session' if you want it to be available across pages.
Please see 'Session variables' at viewtopic.php?f=5&t=7377 for how to do that in Couch.

Hope it helps.
Great, that helps !

For the record, this is what I did:

On the first page, I am storing the URL to redirect to after login:

Code: Select all
<cms:set_session name="redir" value="<cms:show k_page_link />#comments" />


On the login page, I am redirecting to that URL:

Code: Select all
<cms:process_login redirect="0" />               
<cms:redirect url="<cms:get_session 'redir' />" />


It's important to notice, that where-ever you arrive after redirection from login, the first thing to do there is to reset the session variable again. Otherwise, the user will keep on being redirected to that link (if he logs out and in again) for the duration of the session:

Code: Select all
<cms:set_session name="redir" value="<cms:show k_site_link />" />
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
3 posts Page 1 of 1