Cake Version 3.1.2
What I did:
Run the following query in MySQL database:
CREATE TABLE `sessions` (
`id` varchar(255) NOT NULL DEFAULT '',
`data` BLOB, -- or BYTEA for PostgreSQL
`expires` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
);
Change app.php
'Session' => [
'defaults' => 'database',
],
What I wanted:
To have a SessionsController.php
so I can have :
/sessions/add
as the login page and action (allowing GET and POST)/sessions/delete
as the logout page and action (allowing GET and DELETE)/admin/sessions/delete
as a way for admin backend to logout certain users (allowing DELETE)/admin/sessions/index
as a way to fetch all the sessions in a paginated way (allowing GET)Questions in my mind:
Most of the questions you have are answered in the CakePHP Book. The answers to your questions are:
Do I actually bake Session Controller?
A: No, you don't HAVE to bake anything. You can write all the code by hand. Although, I recommend baking to set up the skeleton of the classes.
Is it even possible for me to have SessionsController even when I don't use database to handle my Session?
A: Yes, you can name your controllers anything you want as long as you follow the naming conventions.
How do I bake such a Controller that does not have a default Entity or Table?
A: You just bake it. You don't have to use models, default or otherwise, in your controllers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With