3

My question spawns from me sending an email to the user with something like the following:

http://mydomain.net/login/index/dest/%2Finvitation%2Fconfirm%2Fconfirmation_key%2F15116b5e4c61e4111ade679c10b3bf27

As you can see, what I'm trying to do is pass a url as the parameter "dest" so that the login page will know where to redirect after the user logs in. However, I'm presented with the following:

404 Not Found - /login/index/dest//invitation/confirm/confirmation_key/15116b5e4c61e4111ade679c10b3bf27

This is the View I use to create the email:

<p>
<?if($this->invitation->user):?>
<a href='<?=$this->serverUrl($this->baseUrl().$this->url(array(
    'action'=>'index',
    'controller'=>'login',
    'dest'=>$this->url(array(
        'action'=>'confirm',
        'controller'=>'invitation',
        'confirmation_key'=>$this->invitation->confirmation_key
    ))
)));?>'>Log in to confirm this invitation.</a>

//The view continues...

Any idea on how to keep this from translating the URI encoded items to their literal value would be greatly appreciated.

2
  • 1
    I have a feeling your Login controller is missing the index action? Commented Jul 14, 2011 at 0:13
  • 1
    That is incorrect, but I could see how you could come to that conclusion. However, in the case that my index action was missing, typically, I would see the Error Controller. In this case, it's like some entity (not sure if it's apache or the browser) is decoding the URI encoded items, then navigating to that address. Commented Jul 14, 2011 at 1:48

3 Answers 3

6

Can't you just send it over as a simpel GET parameter?

Like http://mydomain.net/login/index/?redirect=/invitation/confirm/confirmation_key/15116b5e4c61e4111ade679c10b3bf27

That's how it's mostly done actually.

Sign up to request clarification or add additional context in comments.

2 Comments

Sounds like the best solution. I wrote a simple query router a few months ago to tie this type of url into Zend Router if that's any use to you. fullycharged.org/articles/zend-framework/query-router
Thanks ChrisR and Adlawson. The thought to use standard get parameters had crossed my mind but I wanted to make sure that's the way it's "supposed" to be done. Mainly, because I'm new to Zend Framework and there are about an average of 5 ways to do any one thing.
1
  1. What ChrisR wrote is absolutly the answer
  2. Why wouldn't you just use the $_SERVER['referer']

4 Comments

To use $_SERVER['referer'] for this, you would have to put the value in a hidden field in the form so you still have it after the post. Putting it into the URL query string is much cleaner than adding extra DOM elements in my opinion.
I would rather use cookie or session for that, no need for hidden fields in forms (Which in my opinion are cleaner then the url, which can be indexed wrongly)
In this case $_SERVER['referer'] wouldn't work unless they accessed the page directly, then you redirected them back to the login page and stored it some how. I guess there is defiantly a way to do it. Don't really see any of them as "wrong"
@Itay Actually, your idea is a very good one. Send them directly to the Invitation Confirmation page, then since they aren't logged in, send them to the login page storing the URL they hit in the SESSION. At that point, once they log in, read from the session and then send them to that page and remove it from the session. Actually safer that way too... don't have to worry about URL hacking or what not.
0

You can also upgrade your link like this:

<a href='<?=$this->serverUrl($this->baseUrl().$this->url(array(
'action'=>'index',
'controller'=>'login',
'dest'=>base64_encode($this->url(array(
    'action'=>'confirm',
    'controller'=>'invitation',
    'confirmation_key'=>$this->invitation->confirmation_key
))))

));?>'>Log in to confirm this invitation.</a>

But on the /login/index, you will need to use the base64_decode() to get the original Not the most pretty solution, but if you are not able to use the simple querystring, this is a way, how to pass a string via URL safely.

http://en.wikipedia.org/wiki/Base64

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.