CodeIgniter Forums
set_cipher and set_flashdata cannot be used together - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: Issues (https://forum.codeigniter.com/forum-19.html)
+--- Thread: set_cipher and set_flashdata cannot be used together (/thread-61721.html)



set_cipher and set_flashdata cannot be used together - noobie - 05-09-2015

Hello,

Today i noticed a weird issue in CodeIgniter 2.2 (haven't tested this on CI 3 yet), then i installed a fresh CI and tested it and it happened again,

set_flashdata does not work in the following situation (i simplified as much as i could to get the exact reason):

Controller (Simplified):
PHP Code:
<?php

class Welcome extends CI_Controller {

 function 
__construct(){parent::__construct();}

 function 
index()
 {
 
$this->load->library('session');
 
$this->load->library('encrypt');
 
 
$this->encrypt->set_cipher(MCRYPT_BLOWFISH);
 
$this->encrypt->encode('message');
 
 
$this->session->set_flashdata('item''value');
 }



Config:
PHP Code:
$config['sess_encrypt_cookie'] = TRUE// Also set encryption_key config
$config['log_threshold'] = 1// To log the error 

Then when i open my controller and refresh again, Flash Data is not set, and also the following error is logged:

Code:
Severity: Notice  --> unserialize(): Error at offset 0 of 287 bytes /Applications/MAMP/htdocs/clean/system/libraries/Session.php 741

(If i delete either `$this->encrypt->set_cipher(MCRYPT_BLOWFISH);` or `$this->session->set_flashdata('item', 'value');` or change the config i mentioned, it doesn't happen again)

All i wanted to do, is encrypt a simple message with MCRYPT_BLOWFISH because the default encryption method result was too long for this porpuse (for anything else i wanted to use the default encryption)

Am i doing anything wrong or is this an actual bug? because i just followed the User Guide to do this Undecided


RE: set_cipher and set_flashdata cannot be used together - CroNiX - 05-09-2015

Which version of CI are you using? Since you just downloaded it is it v3? If so, the above code is for the v2 version.


RE: set_cipher and set_flashdata cannot be used together - noobie - 05-09-2015

(05-09-2015, 10:36 AM)CroNiX Wrote: Which version of CI are you using? Since you just downloaded it is it v3? If so, the above code is for the v2 version.

As i wrote it in first line of topic, i tested this on CodeIgniter 2.2.2 (fresh install, just changed the mentioned line in config.php and run the controller) and 2.2.1 (my actual project)

I was using a complex code, which wasn't setting flash data, then i started debugging and simplified my code and excluded models to reach the code you see above (it's the simplest way to reproduce this bug)