pocesar / phery-kohana

Kohana 3.3 module with tight integration for Phery.js library https://github.com/pocesar/phery
https://github.com/pocesar/phery-kohana
10 stars 3 forks source link

Bug with Sessions? #3

Closed chrisgo closed 10 years ago

chrisgo commented 10 years ago

I ran into a strange problem with Session::instance()->get() and Session::instance()->set() when using Phery. Basically, it is NOT doing the ->set() properly. I am using the example on the README.md + phery.remote() on the front end

and here is my code

https://gist.github.com/chrisgo/724f53155a42a9f8b211

line 27 and 28 ... the ->get() is returning NULL

I am going to try to find it if I can but not sure where to start. It may be in the setting on the headers 'Content-Type' => 'application/json' ?

using database session if that matters ... changing it to cookie or native has the same issue


Switching to the raw jquery $.post() _was_ working ... updated gist above but now even the jquery raw is broken (trying to code some more things to show what works and what doesn't)

pocesar commented 10 years ago

I think maybe the problem relies on phery trying to starting the session using session_start() that might conflict with Kohana session. I'll take a look

pocesar commented 10 years ago

@chrisgo I've updated phery to not start the session automatically. You may change the config auto_session to false, and use $this->ajax->get_csrf_token() to set the session using Kohana session.

There are two caveats, both Kohana and Phery do a session_write_close(), that means, the $_SESSION becomes read only when the function is called. In Phery, it happens on shutdown. In Kohana, it also happens on shutdown, and might lead to a race condition. Test the latest version and let me know