Codeigniter: Store value of a dropdown into session variable


Excessi0n
26/4/2016 6:52 am
HOME ยป Web Development

I have a dropdown in the login page which fetches company codes and it's respective ID as value. I need to store this particular value (ID) in a session variable so I may use it throughout site. So that when that particular company is selected I may be able to view the details of that particular company. If there is an alternate method for this, kindly let me know.

MODEL:

public function login ()
{
    $user = $this->get_by(array(
    'company_id' => $this->input->post('company_id'),
    'username' => $this->input->post('username'),
    'password' =>
$this->hash($this->input->post('password')),
), TRUE);

$this->session->set_userdata($user);
    if (count($user)) {
        // Log in user
        $data = array(
            'username' => $user->username,
            'id' => $user->id,
            'loggedin' => TRUE,
            'is_admin' => $user->is_admin,
            'company_id' => $user->company_id
        );
        $this->session->set_userdata($data);
        return TRUE;
    }

}

VIEW:

<tr>
    <td>Location</td>
    <td><select class="form-control" id="company_code"
name="company_code" required>
          <option value="0" selected>Select
Company</option>                      
          <?php foreach($locations as $location){
            $selected =
$user->company_id==$location->company_id?"selected='selected'":'';
            echo "<option $selected
value='".$location->company_id."'>".$location->company_code."</option>";
        }?>
        </select>
</td>
</tr>
<tr>
    <td>Username</td>
    <td><?php echo
form_input('username','','class="form-control" placeholder="Enter User
Name"'); ?></td>
</tr>
<tr>
    <td>Password</td>
    <td><?php echo
form_password('password','','class="form-control" placeholder="Enter
Password"'); ?></td>
</tr>
<tr>
    <td></td>
    <td><?php echo form_submit('submit', 'Log in',
'class="btn btn-primary"'); ?></td>
</tr>

I want the above company_id to be posted into a session variable so it maybe used throughout the program. Any help will be greatly appreciated.


Related to : Codeigniter: Store value of a dropdown into session variable
Codeigniter: Store value of a dropdown into session variable
26/4/2016 6:52 am by Excessi0n in Web Development

I have a dropdown in the login page which fetches company codes and it's respective ID as value. I need to store this particular value (ID) in a session variable so I may use it throughout site. So that when that particular company is selected I may be able to view the details of that particular


how to get the selected value of dropdown list of asp.net and store in session variable?
by Pain999 in Web Development

Dim ename As String = DropDownList.SelectedItem.Value

this statement is'nt working
any help is appreciated!!


How to retrieve selected value from the dropdown list in asp.net and store it in session variable?
by dreshyne2g in Web Development

The dropdown list is showing data from database, but how to retrieve the selected value and store it in a session variable?


CodeIgniter: store more information into the session
by Ferzerp in Web Development

this is the function I have, in my login controller, which stores data into an array and then set the userdata


function validate_credentials()
{
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($q
i can`t store session value passing through jquery ajax. in codeigniter php framework
by domis in Web Development

I have a problem storing session value;
I am not able to increment the session count variable
via the AJAX Jquery call with some value passing
to function, also my previously set array which stores the session is change with a new one.


What is the problem here:

TAGS: store session value passing through jquery
Jquery .post used to store php session variable. How to avoid refresh to call session value
by bps in Web Development

I am using jquery's .post ajax call to pull an form input value and pass it to a php file that starts a session and stores the value in it. The session value is then called on a different page.


The problem is, this all takes place without a page refresh, so the session value is always


Why does CodeIgniter store output in a variable?
by mikhaelrasputin in Web Development

i recently looked through CodeIgniter's code just to see how it works.


One thing that i don't understand is why CodeIgniter is storing all the output generated by the views in a single variable and outputting it at the end of the script?


Here's a piece of code from ./s


why session variable returns two records in codeigniter
2/1/2015 12:30 am by Texas in Web Development

I am using codeigniter sessions. When my user logged in session successfully store the data record that i want to store in it and also remove the particular record on the stage of logout. It works properly.

But the problem is when i print the all the data stored in session with the use of


What is the proper way to test CodeIgniter session variable?
by ShayH in Web Development

Take the following code snippet. What is the best way to test to make sure the session variable isn't empty?


<?php if ($this->session->userdata('userID')) {
$loggedIn = 1;
}
else {
$loggedIn = 0;
} ?>

If later in my sc


Get value from chosen select dropdown and store in session
23/12/2014 2:50 pm by Traveling around the world in Web Development

<form id="form_uni" method="post">
            <select id="select_uni" name="select_uni" 
data-placeholder="Choose a University" class="chosen-select"
style="width:400px;" tabindex="2">
            <option value=""></option>
            <?php

            $sql =


HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .