Answer the question
In order to leave comments, you need to log in
Why Kohana 3.3 Error reading session data on any session call after OAuth?
Colleagues!
I don't sleep the second night.
Connected facebook and google oath modules to Kohana.
At first everything worked and I did not notice when everything broke.
Maybe someone has come across something similar?
facebook and google in the process of authentication, create their own session.
This is where the conflict comes in.
When I first encountered this, creating my own session config helped:
<?php defined('SYSPATH') OR die('No direct script access.');
return array(
'native' => array(
'name' => sha1(URL::base()),
'lifetime' => 43200,
'encrypted' => FALSE,
),
'cookie' => array(
'name' => 'cookie_name',
'encrypted' => TRUE,
'lifetime' => 43200,
),
'database' => array(
'name' => 'cookie_name',
'encrypted' => TRUE,
'lifetime' => 43200,
'group' => 'default',
'table' => 'table_name',
'columns' => array(
'session_id' => 'session_id',
'last_active' => 'last_active',
'contents' => 'contents'
),
'gc' => 500,
),
);
Session_Exception [ 1 ]: Error reading session data.
SYSPATH\classes\Kohana\Session.php [ 324 ]
319 }
320 }
321 catch (Exception $e)
322 {
323 // Error reading the session, usually a corrupt session.
324 throw new Session_Exception('Error reading session data.', NULL, Session_Exception::SESSION_CORRUPT);
325 }
326
327 if (is_array($data))
328 {
329 // Load the data locally
SYSPATH\classes\Kohana\Session.php [ 125 ] » Kohana_Session->read(arguments)
SYSPATH\classes\Kohana\Session.php [ 54 ] » Kohana_Session->__construct(arguments)
MODPATH\auth\classes\Kohana\Auth.php [ 58 ] » Kohana_Session::instance(arguments)
MODPATH\auth\classes\Kohana\Auth.php [ 37 ] » Kohana_Auth->__construct(arguments)
APPPATH\classes\Controller\login.php [ 81 ] » Kohana_Auth::instance()
76 {
77 Auth::instance()->force_login($user);
78 $this->redirect('login/login');
79 }
80
81 if(Auth::instance()->logged_in()) {
82 Model::factory('User')->link_user_facebook_id($fb_id);
83 $this->redirect('login/login');
84 } else {
85 $user_data = Model::factory('Facebook')->parse_fb_info($fb->api('/me'));
86 //Model::factory('User')->create_user_from_google_id($user_data);
Answer the question
In order to leave comments, you need to log in
The only clear explanation is here: stupid.su/kohana-3_orm_auth_session
BUT the solution didn't help.
Session conflict
When using the session Native driver and third-party libraries and modules (eg Hybridauth), conflicts may occur due to: the
inability to read/write the encrypted cookie;
use by third-party libraries session_start();
- which can lead to an error:
Session_Exception [ 1 ]: Error reading session data.
The simplest solution would be to use a database to store Kohana sessions, however, there are other solutions, such as passing the current $_session_id to session_start() or replacing it in third-party modules with Session::instance().
Important: the above error can also occur due to the banal impossibility of writing / reading session data, for example, due to unavailability / lack of write permissions in session.save_path (PHP session file storage directory, see php.ini)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question