Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:23:37+00:00 2026-06-11T13:23:37+00:00

I believe the problem is that I am base64_encoding the json string and when

  • 0

I believe the problem is that I am base64_encoding the json string and when I base64_decode the string and run json_decode($string, true) for some reason it just returns the string of ‘Array’.

Here is where I pass the json to be encoded:

$data = '[{"id":"1","name":"Dave","email":"dave@test.com","password":"1610838743cc90e3e4fdda748282d9b8","isAdmin":"true","timeStamp":"2012-09-18 20:37:38"}]';

Session::set('user', $data, true);

Here is my base64 encode/decode code:

public static function set($key, $value, $encrypt = false) {
    if ($encrypt == false) {
        $_SESSION[$key] = $value;
    } else {
        $_SESSION[$key] = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5(SALT1), $value, MCRYPT_MODE_CBC, md5(md5(SALT2))));
    }
}

public static function get($key, $decrypt = false) {
    if (isset($_SESSION[$key])) {
        if ($decrypt == false) {
            return $_SESSION[$key];
        } else {
            return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5(SALT1), base64_decode($_SESSION[$key]), MCRYPT_MODE_CBC, md5(md5(SALT2))), "\0");
        }
    }
}

Then here is where I make the call to decode the value:

$user = Session::get('user', true);

echo json_decode($user, true);

And my result is:

Array

I have looked into the different mcrypt modes, but was unsuccessful in finding a solution. Any help would be greatly appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:23:38+00:00Added an answer on June 11, 2026 at 1:23 pm

    The echo just outputs an string. you will have to use print_r() or var_dump() to view the array.

    print_r(json_decode($user, true));
    

    or use

    var_dump(json_decode($user, true));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe our problem is that we need to run particular builds on a
I believe my problem stems from my use of weights and the RelativeLayout that
THIRD EDIT: I now believe that this problem is due to a SOAP version
I have a problem with some code and I believe it is because of
I have a javascript problem that I believe is related to closures in loops
I'm working on a project and have a problem that I believe can be
I believe I have a very common problem that affects developers with multiple versions
I have a problem that I believe I need to use grouping using xsl:key
I believe this might be one of the most common problem that users faces
Ok.. I have a really awkward problem that I believe is related with how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.