0

HI,
I am using phpcake. I have to check if a user is logged in with some user/pass no other one can use same user/pass till one is logged in.
I have idea it cam be done through the database maintaining the table for logged in users. But I dont wana add new table. Is there any way out doing it with session?

thanks

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by martin5211
0

Yes, we can create a session variable with $this->Session->write("var_name", "value") and then read it with $this->Session->read("var_name").

A global function (maybe into /app/app_controller.php) to check if the session variable exists and redirect to the Login controller would be almost mandatory. Then into the Login controller we'll need two functions, one to perform a variable comparison with the database and redirect to the main controller / admin panel, and the second function to logout (destroy the session variable using $this->Session->delete("var_name")).

In http://bakery.cakephp.org you will find a lot of tutorials, like obAuth Authentication, you can use it completely or as reference.

Good luck!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.