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

  • SEARCH
  • Home
  • 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 7570425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:25:25+00:00 2026-05-30T15:25:25+00:00

I have written my cake app to log in registered users and it works

  • 0

I have written my cake app to log in registered users and it works great on view pages where there is a db model associated with a User. However, on my main pages that aren’t necessarily accessing some model (the PagesController where pages are things like upcoming events, contact us, about, etc), AuthComponent is not available, or at the least, the array returns empty—so i cannot retrieve, say, the username of the person logged in.

I tried creating a model called Page that belongsTo User but that didn’t fix my problem.

To explain a little further, my app shows lists of certain lodgings, nightclubs, restaurants and things to do for a given city, all of which is shown whether a user is logged in or not. I don’t understand where I am going wrong and why.

Here is my AppController:

<?php
class AppController extends Controller {
 public $components = array(
    'Session',
    'Auth' => array(
        'loginRedirect' => array('controller' => 'users', 'action' => 'view'),
        'logoutRedirect' => array('controller' => 'pages', 'action' => 'index')
    )
);


function beforeFilter() {
    $this->Auth->allow('login', 'logout','index', 'view', 'condos', 'houses', 'hotels_and_motels', 'print_all_coupons', 'print_coupon', 'search', 'golf', 'charters', 'events', 'nightlife', 'shopping', 'visitors_info', 'contact_us');

}
}
?>

here is where I access my username in my default page layout:

<?php if(AuthComponent::user('id')) {
        echo '<span style="font-variant:small-caps">Hello, '.AuthComponent::user('username').'</span> | ';
?>
  • 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-30T15:25:26+00:00Added an answer on May 30, 2026 at 3:25 pm

    I have found the answer, after weeks of beating my head on the wall about this. And oh, you’re gonna laugh. For any of you out there up against this problem, the answer is…..make sure there is no white space before or after your tags. That is all. Seriously. Since PHP prints out everything that isn’t in a PHP tag, if it finds something to send, it will send out headers before everything else. Once headers are sent, a PHP session cannot be created. So chalk this one up to the head-smacking file!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this code in JavaScript and works perfectly fine when I include
I have written an Android app (target 3.2) using Eclipse 3.7, I tried to
I have written a app in PHP on my localhost server using XAMP, which
I have written a simple program in MASM, like: .386 .model flat, stdcall option
have written this little class, which generates a UUID every time an object of
I have written a bash script which installs a number of packages, however for
I have written this code inside a servlet to delete certain records from three
I have written a function that sorts a big scale of data. To test
I have written a java program generates lots of files (say txt files) in
I have written a function that extract the domain from hostname. e.g. www.domain.com ->

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.