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 8284805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:14:41+00:00 2026-06-08T11:14:41+00:00

I am having issues accessing session information upon login. I am using Nice Auth

  • 0

I am having issues accessing session information upon login. I am using Nice Auth a plugin for CakePHP.

I have followed some instructions here

What I am trying to do is access the users username so that on another page they do not need to fill out who they are when they send a support ticket.

This is the Userscontroller login function:

public function login(){
        if ($this->request->is('post') || ($this->request->is('get') && isset($this->request->query['openid_mode']))) {
            if ($this->Auth->login()) {
                $this->redirect($this->Auth->redirect());
                }
            else {
                $this->Session->setFlash(__('Invalid username or password, try again'));
                }
            }
        }

Which is where I would assume I put the

$this->Session->write('User.id', $userId);

Below is the tickets controller:

public function send()
    {
        $userId = $this->Auth->user();
        if ( !empty($this->request->data) )
        {
            $email = new CakeEmail();
            $email->from(array('xxxx@example.com'))
                //->to($this->request->data['to'])
                ->to(array('helpdesk@example.com'))
                ->subject($this->request->data['subject']);

            if ($email->send($this->request->data['message']))
            {
                $this->Session->setFlash(__('Email Sent Successfully'),
                    'default', array('class' => 'success'));
            }
        }

    }

Where I would expect to put this code:

$userId = $this->Session->read('User.id');

And then to display in my View:

$userId = $session->read('User.id');

Now, I have added the Session Component and Helpers to the files as I thought that would be what was causing me issues, but No dice!

Any help is greatly appreciated.

My Current error messages look like this:

Notice (8): Undefined variable: session [APP/View/Tickets/send.ctp, line 10] Fatal error: Call to a member function read() on a non-object in /Users/bellis/workspace/cake/app/View/Tickets/send.ctp on line 10
  • 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-06-08T11:14:43+00:00Added an answer on June 8, 2026 at 11:14 am

    Turns out, the recommended method is to do it like this:

    $userId = $this->Auth->user('id');
    

    You can access the logged in user via that method from any controller.

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

Sidebar

Related Questions

all! I'm having some issues accessing an XML node's properties using Javascript. The XML
Having some issues accessing my param tags from within actionscript. Essentially I have the
I'm trying to designing a class and I'm having issues with accessing some of
Just in the last week I have been having issues with accessing a JBoss
im developing a small application with login and having an issue accessing session data.
I'm testing ZF2 beta4 at the moment, and I'm having some issues accessing some
I am using the core Auth component. I have created a user login that
I am having issues accessing public variables from an object in a prototyped function...
Am having issues with printing different sized PDF's using GhostScript (V9.05). The PDF in
Im having issues getting this to work, maybe its not even possible? I have

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.