Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the action name of referer url (previous url) in cakephp

I've the referer url which is from $this->referer() is given below

http://localhost/project/users/login

And i want to get action of the referer url (previous url),

How can i get it ?

Thanks

like image 631
Anil kumar Avatar asked Dec 24 '22 07:12

Anil kumar


1 Answers

To get the referer full base url, we use $this->referer(), if you parse Router::parse($this->referer()); we get an empty array

but to restrict referring urls to local server, you've to use pass additional param like below

$refer_url = $this->referer('/', true); // you get like "/project/users/login"

Now if you parse the above returned value $parse_url_params = Router::parse($refer_url);

you'll get the details of Controller, Action & Plugin

Here are the details:

Array ( 
    [plugin] =>  
    [controller] => users 
    [action] => login 
    [named] => Array () 
    [pass] => Array ( ) 
)
like image 148
Anil kumar Avatar answered May 07 '23 05:05

Anil kumar