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

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.