![]() |
cannot set an index of a session - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: cannot set an index of a session (/showthread.php?tid=71084) |
cannot set an index of a session - hamidb80 - 07-04-2018 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? RE: cannot set an index of a session - InsiteFX - 07-04-2018 You need to read the CodeIgniter User's Guide PHP Code: $this->session->set_userdata('coins', '5'); RE: cannot set an index of a session - hamidb80 - 07-04-2018 (07-04-2018, 03:44 AM)InsiteFX Wrote: You need to read the CodeIgniter User's Guide No, This is my session: PHP Code: array( I want to change user coins. RE: cannot set an index of a session - Paradinight - 07-04-2018 (07-04-2018, 06:36 AM)hamidb80 Wrote:(07-04-2018, 03:44 AM)InsiteFX Wrote: You need to read the CodeIgniter User's Guide https://www.codeigniter.com/user_guide/libraries/sessions.html?highlight=set_userdata#adding-session-data RE: cannot set an index of a session - dave friend - 07-04-2018 (07-04-2018, 01:31 AM)hamidb80 Wrote: Hello. I try to change an index of a session but codeigniter sent an Error : 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); Code: array (size=2) |