Passing a URL as a URL parameter
I am implementing OpenId login in a CakePHP application. At a certain point, I need to redirect to another action, while preserving the information about the OpenId identity, which is itself a URL (with GET parameters), for instance
https://www.google.com/accounts/o8/id?id=31g2iy321i3y1idh43q7tyYgdsjhd863Es
How do I pass this data? The first attempt would be
function openid() {
...
$this->redirect(array('controller' => 'users', 'action' => 'openid_create', $openid));
}
but the obvious problem is that this completely messes up the way CakePHP parses URL parameters.
I'd need to do either of the following:
1) encode the URL in a CakePHP friendly manner for passing it, and decoding it after that, or
2) pass the URL as a POST parameter
but I don't know how to do this.
EDIT: In response to comments, I should be more clear. I am using the OpenId component, and I have a working OpenId implementation. What I need to do is to link OpenId with an existing user system. When a new user logs in via OpenId, I ask for more details, and then create a new use开发者_运维技巧r with this data. The problem is that I have to keep the OpenId URL throughout this process.
My suggestion is to store the url in the session.
My first suggestion would be to try PHP's urlencode() and urldecode() functions, but I'm not entirely sure what will happen when you encode and decode stuff that's already been url-encoded for the parameters of the OpenID identities.
You can try this way:
$this->redirect(array(
'controller' => 'users',
'action' => 'openid_create',
'?' => array('id' => $openid)
));
精彩评论