开发者

Kohana 3.2 regenerating session id on every request

i hope this h开发者_如何转开发asn't already been answered, I've looked through for awhile and haven't really seen an answer.

I am using Kohana 3.2 sessions with database driver. The problem is that every time the page is loaded or refreshed, it is creating a new session id.

I've set the Session::$default = 'database' in my bootstrap. My session config looks like this:

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
         */
        'name'     => 'trucero_session',
        'lifetime' => 1200,
        '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'
        ),
    ),
);

Thank you in advance.


I don't think Laurent really understood your question, because there should be only one single session id created and used between page refreshes - that's the whole point of having sessions is so you can re-use the same session every time when you access a page.

A new session ID is created when you open the page either with a new browser, or close the existing browser and then open a new one, or destroy the current session (like by logging out from your page) and then create a new one (..by logging in).

But I did find a similar problem in Kohana 3.2 where my scripts were generating multiple session IDs per each page read and the sessions weren't being "read" back because a new session_id was created at each page refresh/access. I was able to track this issue down to Google Chrome browser (in my case) and after digging around I found this post:

http://forum.kohanaframework.org/discussion/10303/session-problem-with-ie-and-chrome/p1

Which basically says that you have to set Cookie::domain to either FALSE or to a specific domain for the Kohana database session to work properly in Chrome and in IE.


You cannot rely on the session ID because it's indeed regenerated on every request. If you need some sort of ID, you'll have to use a custom one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜