Welcome Guest, Not a member yet? Register   Sign In
How to update certain session
#1

Hi,  I have problem with codeigniter session. I want update certain session. Example I store my email, username, and user_lvl in session. If I change/update email in user profile and I click submit button. The new email will update in session.

This is how I store my session in codeigniter:

PHP Code:
$setSession= array(
        'username' => 'admin',
        'email'    => '[email protected]',
        
'user_lvl' => 1,
);
    
$this
->session->set_userdata('logged_in'$setSession); 
Note: I just want update email in session only.
This is me. JK not me.
Reply
#2

@falcon812311,

Here is the CI documentation on session variables: https://codeigniter.com/user_guide/libra...sion-class

It shows how to update a session variable. All that is necessary is placing it at the right location in your code to update.
Reply
#3

(This post was last modified: 06-26-2018, 09:27 AM by dave friend.)

Very easy.

PHP Code:
$_SESSION['email'] = "[email protected]"

This will also work.

PHP Code:
$this->session->email  "[email protected]"

The first is slightly more efficient and is what the documentation recommends. (See second paragraph of the linked documentation section.)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB