Welcome Guest, Not a member yet? Register   Sign In
How to add session data without using set_userdata? The docs doesn't have an example.
#1

Hi,
The documentation has an example of how to add data using set_userdata.
PHP Code:
$newdata = array(
        'username'  => 'johndoe',
        'email'    => '[email protected]',
        'logged_in' => TRUE
);

$this->session->set_userdata($newdata); 
But it says too "You can simply assign data to the $_SESSION array, as with any other variable. Or as a property of  $this->session."

Sorry, but I don't get it. How can I do that with the same example above without using set_userdata?

Cheers!
Reply
#2

(01-14-2022, 05:22 AM)castle Wrote: Hi,
The documentation has an example of how to add data using set_userdata.
PHP Code:
$newdata = array(
        'username'  => 'johndoe',
        'email'    => '[email protected]',
        'logged_in' => TRUE
);

$this->session->set_userdata($newdata); 
But it says too "You can simply assign data to the $_SESSION array, as with any other variable. Or as a property of  $this->session."

Sorry, but I don't get it. How can I do that with the same example above without using set_userdata?

Cheers!

You can use the session helper 

PHP Code:
session()->set('key',$newdata

or 

PHP Code:
$_SESSION['key'] = $newdata 
Reply
#3

How about

PHP Code:
$this->session->language $language


Is it ok to do that?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB