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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:14:39+00:00 2026-06-14T09:14:39+00:00

I have a users first and last name stored in session data and I

  • 0

I have a users first and last name stored in session data and I want to echo it out in the view so they can see who they are logged in as. I can’t seem to get the data to pass. I’m sure this is something easy but I’m pretty new to CI and the whole MVC thing.

Controller Code:

public function index() {
    if($this->session->userdata('admin_signed_in')){
    $this->load->model('dashboard_model');
    $data['userdata'] = $this->session->userdata;
    $data['main_content'] = 'dashboard/dashboard';  
    $this->load->view('common/template', $data);
    } else {
    redirect('signin');
    }

}

View Code:

<?php echo $userdata('first_name') ?>  <?php echo $userdata('last_name') ?>

Print R Results:

Array ( [session_id] => 69db0f9ccbfde96d92cc09837067438c [ip_address] => ::1 [user_agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0 [last_activity] => 1352998508 [user_data] => [0] => Array ( [admin_id] => 10 [first_name] => Richard [last_name] => Coy [admin_role] => 1 ) [admin_signed_in] => 1 ) 
  • 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-14T09:14:41+00:00Added an answer on June 14, 2026 at 9:14 am

    Controller code:

    public function index() {
    
        ...
        $data['first_name'] = $this->session->userdata('first_name');
        ...
    }
    

    View code:

    <?= $first_name; ?>
    

    OR, if you want to pass the data like you currently are, you would access the view data userdata as an array, not a function, ie:

    <?= $userdata['first_name'];?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Regex - Return First and Last Name Hi, I have the full
I have created a web form with the following values first name last name
I have an a users friends stored in the database as friends_array . They
I'm using cakePHP and I want to add a First and Last name column
Right now i have a column called full_name where the first and last name
I have two tables: Users: ID, first_name, last_name Networks: user_id, friend_id, status I want
I have a requirement where I have to register users first via email. So,
First off thanks to all the users who have made my android developing adventure
I am trying to extend the fields in django-reg (with First name, last name
I have a table called Users that stores generic user information (user id, first,

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.