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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:04:22+00:00 2026-06-12T08:04:22+00:00

When a user logs in they are directed to my log in function —

  • 0

When a user logs in they are directed to my log in function — Here is my partially working code. I commented out the parts that I need help with.

model

    if ($query->num_rows() == 1)
    { 
        return $query->row()->f_name;
    }   
        
    else {
        return false;
    }

}

controller

    if($this->form_validation->run()) {
    $f_name = $this->model_users->can_log_in();
        $data = array(
            'email' => $this->input->post('email'),
            'is_logged_in' => 1,
            'name' => $f_name
            );
            
        $this->session->set_userdata($data);
        
        redirect('account_dashboard');  

The user’s name is in the database table with their email/pw. I want to get the users f_name and set it in the session when they log in since the session is a global var.

view

my header shows their name:

echo $this->session->userdata('name'); 

How do I get db_values from the table and pass them along to the session?

  • 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-12T08:04:24+00:00Added an answer on June 12, 2026 at 8:04 am

    When you call $query->row(), it will return the first row from the query results as an object. So, if you need to return the user’s first name, which in this case is stored under the f_name field, you’ll want to write this:

    return $query->row()->f_name;
    

    Then in your controller, you’ll have the first name returned from the model function.

    $f_name = $this->model_name->model_function_name();
    $data = array('email' => $this->input->post('email'),
                  'is_logged_in' => 1,
                  'name' => $f_name
    );
    

    In case you need more than just the user’s first name in your controller, return the whole row from the model function instead.

    return $query->row();
    

    Then in your, controller you can access the returned object (or array if you use row_array()), by accessing its properties which will be named based on the fields’ name in the database table.

    $user = $this->model_name->model_function_name();
    $f_name = $user->f_name; // Get the user's first name
    $other = $user->other; // Get some other information
    

    It works the same way too for row_array(), but of course, you’ll need to do something like $user['f_name'] instead of $user->f_name.

    EDIT: Also, make sure the model is loaded by the controller, before you try to call its functions.

    $this->load->model('model_name');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The issue here is that when my user logs into my app, they always
So here is the problem. When a user logs out of my website, they
As per FB policies, when a user logs out of my site they are
I have a website and when the user logs in they can click on
I have a pop-up window a user logs into, once they are logged in
I have a database that contains user details including sensitive data. They're not as
Once a user logs into their account, they are presented with a list of
Where I work they use the AppletContext.showDocument(URL) method when a user logs off our
We have a website (foo.com) that does online training. A user logs in, then
I need to create a Windows service that checks when a user logs in

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.