Base64 decode not giving value in php-ThrowExceptions

Exception or error:

I have a post value from a form, which contains an array. This value is first serialized and then base64 encoded before it is put in a session.

Now on the page where the data is needed, when i print_r to screen, i can see the value stored in the session as

YToxOntpOjA7czo1OiIzNTAwMCI7fQ==

Which is actually 35000.

But on this page where i am supposed to retrieve the data from the session, i am able to get the value from the session and store in a variable

$screeningamountt = $_SESSION['SCREENINGAMOUNT'];

But when i try to first unserialize and base64 decode the varaible to get the data which is supposed to be 35000, I get an empty variable. Noting prints to screen.

$screeningamount = base64_decode(unserialize($screeningamountt));

I can’t figure out whats happening. Any help to figuring whats going on is much appreciated.

How to solve:

If you serialize it first then base64 encode it you need to unencode it then unserialize.

Last in, first out.

$screeningamount = unserialize(base64_decode($screeningamountt));

Leave a Reply

Your email address will not be published. Required fields are marked *