1

when i load my controller i have this:

$this->load->library('encrypt');

$get = null;
parse_str($_SERVER['QUERY_STRING'],$get);
$email = $this->encrypt->decode($get["acc"]); // e.g.  www.lol.com/?acc=troll

And my controller is called like this:

$this->load->library('encrypt');
$this->load->helper("url");
$user = $this->input->post('email', true);

$encrypted_string = $this->encrypt->encode($user);
redirect('account/viewaccount?acc='.$encrypted_string);

The url looks like this:

http://localhost/CodeIgniter/index.php/account/viewaccount?acc=+fgSAs6X7ysW6XDjFVw//9RGVbY751zZv1LQ44yYBjhVuzI1BC1t9BbZCIUdX5lpYA==

But the problem is, when i encode i get a value, but then later on, when i decode this huge value (I can receive this value flawless, by testing) it returns nothing, just NULL.

Why is this happening?

Thank You

3 Answers 3

3

The output of the encryption is not URL safe. Replace this:

redirect('account/viewaccount?acc='.$encrypted_string);

With

redirect('account/viewaccount?acc='.urlencode($encrypted_string));

And then urldecode() it on the other end.

Sign up to request clarification or add additional context in comments.

Comments

0

Encoded form is not url safe, try using some other encoding technique or urlencode the output of encode.

2 Comments

I don't know why, but when i used your urlencode on the encoded value, and then urldecode on the decoded value of the encoded, it worked :/
The output of $this->encrypt->encode($user); has special characters like //, which breaks the url and you don't receive complete encoded value.
0

try encrypting a string and decrypt it. the error may not be the decryption or encryption

1 Comment

ahh so try to put it in a session or a cookie. beacause you can find an code error, and you can (if you want access the string) at any page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.