Log message #4033536

# At Username Text
# May 29th 2017, 20:20 lorenzo np :slightly_smiling_face:
# May 29th 2017, 20:20 chris-andre Typo. Thanks :slightly_smiling_face:
# May 29th 2017, 20:19 chris-andre Ah.
# May 29th 2017, 20:19 lorenzo it should be `$this->request->session()->id()`
# May 29th 2017, 20:19 lorenzo the problem is here `$this->request->sessions()->id()`
# May 29th 2017, 20:19 lorenzo ah ok, then it has nothing to do with using the model
# May 29th 2017, 20:18 chris-andre > Method sessions does not exist
# May 29th 2017, 20:17 lorenzo @chris-andre and what’s the error you’re getting?
# May 29th 2017, 20:11 chris-andre Last try was with TableRegistry, as you can see.
# May 29th 2017, 20:10 chris-andre @lorenzo Yes. Here is my controller action: https://gist.github.com/chris-andre/b22b1592702e5d3cc8081a3a74c7372c
# May 29th 2017, 19:36 lorenzo are you sure you are executing that in the context of a controller?
# May 29th 2017, 19:35 lorenzo `loadModel` is a method of all controllers
# May 29th 2017, 19:19 chris-andre Can't sessions table be loaded like other tables/models? I have tried `TableRegistry::get()` as well. Worked inside a component, but not in my controller. Any ideas?
# May 29th 2017, 19:18 chris-andre I'm trying to `$this->loadModel('Sessions')` in my controller, but I get > Method doesn't exists.
# May 29th 2017, 17:45 JD-Robbs tell Blurb
# May 29th 2017, 17:45 JD-Robbs ~tell Test
# May 29th 2017, 17:45 JD-Robbs test
# May 29th 2017, 16:45 chris-andre If so, I have to do some custom code to add the user_id to the sessions table. Will look into it later. GF is pushing me out of my chair. Thanks @hmic
# May 29th 2017, 16:41 chris-andre That is the table.
# May 29th 2017, 16:40 chris-andre https://book.cakephp.org/3.0/en/development/sessions.html#database-sessions
# May 29th 2017, 16:39 hmic you have the user_id in the sessiontable!
# May 29th 2017, 16:39 hmic no
# May 29th 2017, 16:39 chris-andre Yes, okay. Could do. Then I will have to look through every record until I have a match in Sessions.data
# May 29th 2017, 16:37 hmic you don't. you do have the user_id in the session table, just delete the entry/ies that match the user that got changed
# May 29th 2017, 16:37 chris-andre Right
# May 29th 2017, 16:36 hmic well, usually you need the user session data to be reevaluated if you change something like their permissions. at least that is the example case...
# May 29th 2017, 16:36 chris-andre Yes, but still I will need a join table to track the session
# May 29th 2017, 16:35 hmic just ~3 lines of code in an afterSave event of the user table and you are done
# May 29th 2017, 16:35 chris-andre Allright :slightly_smiling_face: Thanks. I doubt I can prove you wrong by now, so I guess I will go with deleting session.
# May 29th 2017, 16:35 hmic - event on save of userdata. you can unconditionally delete that data from the session table, if the user is not logged in, it does not matter anyways.
# May 29th 2017, 16:34 hmic if you think that is good practise too - just delete the session table entry with the user_id you have just changed
# May 29th 2017, 16:34 hmic i don't consider anything besides that good practise! you might come up with a case that proves me wrong though :d
# May 29th 2017, 16:33 chris-andre Okay. Should be okay.
# May 29th 2017, 16:33 hmic the simple - and usual - thing to do, if *important* data on a user changes is just logging that user out!
# May 29th 2017, 16:32 chris-andre Okay. Then we are on the same page. Can I ask, how should I update SessionsTable? By Auth->setUser()? Or is that considered wrong?
# May 29th 2017, 16:29 chris-andre Allright. I misunderstood you.
# May 29th 2017, 16:29 chris-andre Do you mean updating the user session (db) ?
# May 29th 2017, 16:29 hmic updating the session data is about updating the session data, not the user data!
# May 29th 2017, 16:28 chris-andre When I say updating user data, I mean updating data in the UsersTable
# May 29th 2017, 16:28 chris-andre Wondering why data isn't changed when updating user data then :S
# May 29th 2017, 16:28 hmic where else do you think the data would be stored? :d