I am working on a Social Network application with Codeigniter 3, Ion-Auth and Bootstrap 4. You can see the Github repo HERE.
When editing a user's profile, I check if there is a new user photo (avatar) in the edit form. If it is, I use it, if not I use (keep) the one already existing in the users
table (file path is application/controllers/Auth.php
):
$new_file = $this->upload->data('file_name');
$this->file_name = (isset($new_file) && !empty($new_file)) ? $new_file : $user->avatar;
The above code works fine.
However, I need update the user's photo within the session and for this purpose I added just below $this->file_name = (isset($new_file) && !empty($new_file)) ? $new_file : $user->avatar
:
if (isset($new_file) && !empty($new_file)) {
$this->session->userdata('user_avatar') = $new_file;
}
The above if statement causes the error "Can't use method return value in write context".
What am I doing wrong?