0

I have a small problem. I am sending a mail when an item needs attention. I am getting the encrypted string, but when I decrypt it I get nothing .. Anything wrong in my code? Thanks in advance

Encrypting parameter (ID):

$this->load->library('encrypt');
$yes = site_url('job/itemFree/?id='.$this->encrypt->encode($itemid));
$no = site_url('job/itemExtend/?id='.$this->encrypt->encode($itemid));

Decrypting :

$this->load->library('encrypt');
$id = $_GET['id'];
$id = $this->encrypt->decode($id);
echo $id;
4
  • Not sure about this, but I guess there are some special setting changes that need to be done in CI to properly receive GET parameters, can you check by var_dump($_GET) that you are getting 'id' in it ? Commented Dec 5, 2013 at 8:42
  • Could it be that your encrypted strings are not URI-safe? I would use base64encode for uri-safe strings. Commented Dec 5, 2013 at 8:42
  • I am getting this as output : array(1) { ["id"]=> string(88) "xxx==" } Commented Dec 5, 2013 at 8:47
  • if this code is working then posted code must have same output.. Commented Dec 5, 2013 at 8:56

2 Answers 2

1

try this

$this->load->library('encrypt');
$yes = site_url('job/itemFree/?id='.urlencode($this->encrypt->encode($itemid)));
$no = site_url('job/itemFree/?id='.urlencode($this->encrypt->encode($itemid)));
Sign up to request clarification or add additional context in comments.

Comments

0

instead of passing parameter in id using get you can do it like this

$this->load->library('encrypt');
$yes    =   site_url('job/itemFree/'.$this->encrypt->encode($itemid));
$no     =   site_url('job/itemExtend/'.$this->encrypt->encode($itemid));

Now to get it you need to do.

$this->load->library('encrypt');
$id         =   $this->uri->segment(3);
$decoded_id =   $this->encrypt->decode($id);
echo $decoded_id;   

Comments

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.