Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6472409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:20:28+00:00 2026-05-25T06:20:28+00:00

In CakePHP when you try to access a protect action you are automatically taken

  • 0

In CakePHP when you try to access a protect action you are automatically taken to the login form within your app. However the HTTP_REFERER is empty????

$referer = env('HTTP_REFERER');

echo $referer;

So normally when I visit the login page I will see the previous page URL with this code displayed, but if I visit the login page after being taken there by the Auth Component then it will be empty…

why is it empty? as I was just referred???

and how do I get it to acknowledge the redirect as a referal? NOTE: Using the Auth.Redirect session value is not an option in this case because it will stay around after the person has left the site, so for example if they return to the login page it will show the ORIGINAL requested action and NOT the referred page! So it will act as a referral even when its not because it’s using the existing session

EDIT:

As an alternate example:

    if(isset($_SERVER['HTTP_REFERER'])) {
        echo $_SERVER['HTTP_REFERER'];
    }
    else
    {
        echo 'their was no referer';
    }

When the user is taken to the login form it will say their was no referer but that’s obviously not TRUE! ????

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:20:29+00:00Added an answer on May 25, 2026 at 6:20 am

    HTTP_REFERER is a way of the browser to tell the server what page the user was visiting before. It does not signal what page the user has just been redirected from.

    Take for example the Ads on Stackoverflow here. Clicking on one of them will take you to some long URL at adzerk.net, which records your click and then redirects you to the target URL. The intermediate Adzerk page is not an interesting page in itself and the user is never actually seeing it, unless he’s paying close attention to the address bar. In fact there isn’t even a “page” there. So it doesn’t count as a “page visit”. The next page will receive stackoverflow.com as the referer, the intermediate redirect page is irrelevant.

    Stackoverflow -> Adzerk redirect -> Some advertiser
                                        HTTP_REFERER: stackoverflow.com
    

    There’s also no referer at all if you type an address into the address bar. If you’re on Stackoverflow and type yahoo.com into the address bar, Yahoo will not see any referer from you. If you click on a link that takes you from Stackoverflow to Yahoo, the browser does send a referer.

    In your case, if you directly access a protected action by typing it in the address bar and get redirected, there simply is no previous page you came from.


    As per the comments, here how to inject data into the URL while redirecting:

    AppController extends Controller {
    
        function redirect($url, $status = null, $exit = true) {
            if (is_array($url)) {
                $url['?'] = 'redirect=true';
            } else {
                $url.= '?redirect=true';
            }
            return parent::redirect($url, $status, $exit);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue with cakephp's login functionality. When I try to login under
I try to send data form ajax to cakephp cotroller function loadtooltip(obj, $user_id) {
In CakePHP view, When I try this code <?php echo $form->input('download_link', array('type'=>file)); ?>> whose
In a CakePHP 1.2 app, I'm using <?php $session->flash();?> to output messages like Record
I suffered a CakePHP Route Problem. I can only access the root / and
I am working on CakePHP, and I have my app working in my localhost.
What's best method within cakephp site for- two dropdowns one listing cds, one listing
In cakePHP 1.3 , when I try to get the variables GET sent on
I am getting this error when I try to run a CakePHP 2.1 Shell
I'm getting this error when I try to mail from CakePHP 2.0 using CakeEmail:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.