Welcome Guest, Not a member yet? Register   Sign In
Session class you are required to set an encryption key
#1

[eluser]davy_yg[/eluser]

Hello,

I have this codes:


Code:
<?php

class Login extends CI_Controller {

function index()
{
  $data['main_content'] = 'login_form';
  $this->load->view('includes/template', $data);
}

function validate_credentials()
{
  $this->load->model('membership_model');
  $query = $this->membership_model->validate();

  if($query) // user's credential validated..
  {
   $data = array(
    'username' => $this->input->post('username'),
    'is_logged_in' => true
   );
  
   $this->session->set_userdata('data');
   redirect('site/members_area');
  }

  else
  {
   $this->index();  
  }
  

}

}


?>

and I receive this error:

An Error Was Encountered

In order to use the Session class you are required to set an encryption key in your config file.

How to fix this problem?


#2

[eluser]InsiteFX[/eluser]
./application/config/config.php

Thats where you set your encryption key.
#3

[eluser]davy_yg[/eluser]

I just add this code in my config file:

$config['encryption_key'] = 'AbcDeFGHIJkLMn';

The error still remains.
#4

[eluser]Otemu[/eluser]
Quote:Your key should be 32 characters in length (128 bits). The key should be as random a string as you can concoct, with numbers and uppercase and lowercase letters. Your key should not be a simple text string. In order to be cryptographically secure it needs to be as random as possible.
#5

[eluser]InsiteFX[/eluser]
Did you load the session class?

Use a key something like this:
Code:
$config['encryption_key'] = '026914-69125-034179-72360-345729';




Theme © iAndrew 2016 - Forum software by © MyBB