Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error message while logging in in Kohana

I'm using Kohana 3 and I have an issue while logging in with an user.

I use this line to log in:

$success = Auth::instance()->login($_POST['login_user'], $_POST['login_password'], $remember);

And I got this error message:

Session_Exception [ 1 ]: Error reading session data. ~ SYSPATH/classes/kohana/session.php [ 326 ]

I have the sessions table created with the follow SQL:

CREATE TABLE `sessions` (
  `session_id` varchar(24) NOT NULL,
  `last_active` int(10) unsigned DEFAULT NULL,
  `contents` text,
  PRIMARY KEY (`session_id`),
  KEY `sessions_fk1` (`last_active`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

And also the session.php inside the config folder:

<?php defined('SYSPATH') or die('No direct script access.');

return array(
    'database' => array(
        /**
         * Database settings for session storage.
         *
         * string   group  configuation group name
         * string   table  session table name
         * integer  gc     number of requests before gc is invoked
         * columns  array  custom column names
         */
        'group'   => 'default',
        'table'   => 'sessions',
        'gc'      => 500,
        'columns' => array(
            /**
             * session_id:  session identifier
             * last_active: timestamp of the last activity
             * contents:    serialized session data
             */
            'session_id'  => 'session_id',
            'last_active' => 'last_active',
            'contents'    => 'contents'
        ),
    ),
);

?>

What might be the problem here?

Thanks!

like image 256
Felipe Peña Avatar asked Nov 17 '25 09:11

Felipe Peña


1 Answers

I don't know if this will help, but I had a similiar problem.

The cause of this was that using one library (Facebook SDK), session was initialized on it's onw, and session handling was done using the $_SESSION variable. I noticed that there were two cookies - session (Kohanas session id) and PHPSESSID. This probably was the problems cause.

I modified the library so that id doesn't start the session on its own and the problem was solved.

So, you should probalby check if session isn't started elsewhere.

like image 86
Mārtiņš Briedis Avatar answered Nov 20 '25 00:11

Mārtiņš Briedis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!