tags:

views:

157

answers:

3

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 user with this data. The problem is that I have to keep the OpenId URL throughout this process.

A: 

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.

Matt Gibson
+6  A: 

My suggestion is to store the url in the session.

dhofstet
Wow, it was as simple as that! :-D
Andrea
A: 

You can try this way:

$this->redirect(array(
    'controller' => 'users',
    'action' => 'openid_create',
    '?' => array('id' => $openid)
));
bancer