Welcome Guest, Not a member yet? Register   Sign In
cannot set an index of a session
#5

(This post was last modified: 07-04-2018, 03:13 PM by dave friend.)

(07-04-2018, 01:31 AM)hamidb80 Wrote: Hello. I try to change an index of a session but codeigniter sent an Error :

PHP Code:
$this->session->user['coins'] = 5


Code:
Indirect modification of overloaded property CI_Session::$user has no effect

But I didn't send any Error with following code:

PHP Code:
$_SESSION['user']['coins'] = 5

Is there any solution?

I think what you were trying to do is

PHP Code:
$this->session->user = ['coins' => 5]; 

Which produces the exact same result as

PHP Code:
$_SESSION['user']['coins'] = 5

After either of the above is run
PHP Code:
var_dump($_SESSION); 
produces


Code:
array (size=2)
 '__ci_last_regenerate' => int blah-blah-blah
 'user' =>
     array (size=1)
       'coins' => int 5
Reply


Messages In This Thread
cannot set an index of a session - by hamidb80 - 07-04-2018, 01:31 AM
RE: cannot set an index of a session - by dave friend - 07-04-2018, 03:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB