Problem when decoding json?

<input type="hidden" name="user_session" value="<?=$user['session']?>">

$session = $_POST['user_session'];

$user['session'] = ["example1", "example2"]; // type string is not yet decrypted
When printing prints: [
I think that the thing in quotes, but how to solve I don't know.
April 7th 20 at 15:27
1 answer
April 7th 20 at 15:29
<input type="hidden" name="user_session" value="<?= json_encode($user['session']) ?>">

and on the server:

$session = json_decode($_POST['user_session']);

you can use serialize\unserialize
I have value and so the json. Decided the whitespace so:
Changed double quotes to single quotes. Not sure just what is the best way. - Glennie_Ter commented on April 7th 20 at 15:32
@cadeYeah, all right. Should be single quotes, as in JSON on the standard double. - Akeem_Erdman26 commented on April 7th 20 at 15:35

Find more questions by tags PHP