Juergen Posted August 2, 2017 Share Posted August 2, 2017 Hello @ all, I have a user profile frontend form and I want to show a message what has been changed after submitting the form. Therefore I have created an array which contains the original user data before something will be changed in the DB. //create array of stored user data $valuesbefore = array( $user->fields->get('usergender')->$label => $user->usergender->id, $user->fields->get("user_first_name")->$label => $user->user_first_name, $user->fields->get("user_real_name")->$label => $user->user_real_name, $user->fields->get('email')->$label => $user->email, _t('Username', 'Login') => $user->name, $user->fields->get('pass')->$label => $user->pass, $user->fields->get('language')->$label => $user->language->id, $user->fields->get("userimage")->$label => $user->userimage ); $session->valuesbefore = $valuesbefore; I have called it $valuesbefore. After that I have started (created) a new session (name=valuesbefore) which should hold the array with the original userdata for comparing with the new userdata after form submission. This piece of code is after the POST command. My problem is that if I use an array inside the session I will always be logged out after form submission. If I use a string everthing is ok. Is there a limitation of using arrays inside the PW session function? Best regards Jürgen Link to comment Share on other sites More sharing options...
Juergen Posted August 2, 2017 Author Share Posted August 2, 2017 Anyway, I use another solution: I convert the array into a json object, put it into the session variable and afterwards I convert it back to an array like this. Inside $Post $valuesbefore = array( $user->fields->get('usergender')->$label => $user->usergender->id, $user->fields->get("user_first_name")->$label => $user->user_first_name, $user->fields->get("user_real_name")->$label => $user->user_real_name, $user->fields->get('email')->$label => $user->email, _t('Username', 'Login') => $user->name, //$user->fields->get('pass')->$label => 'yes', $user->fields->get('language')->$label => $user->language->id, $user->fields->get('userimage')->$label => $user->userimage->basename, 'Password' => 'no'//special type ); $valuesbefore = json_encode($valuesbefore); $session->predata = $valuesbefore; The session variable predata holds the json array and after submission I grab this session variable and convert it back to a php array like this: $valuesbefore = json_decode($session->predata, true); Now I have submitted a session with an array 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now