Welcome Guest, Not a member yet? Register   Sign In
Basic user class
#1

[eluser]merik[/eluser]
I want some basic user management in my project. I can't use CI's Session class, because it stores the user data either in a cookie or a database. I want the session data to be stored in the memory instead; right now, I am using $_SESSION which works but I have to keep track of managing numerous session variables.

I was thinking of creating a user management library, which stores all user session information in ONE serialized session variable, and has methods that you can use to see if the user is logged in or not, if they have permissions to do a certain thing, etc etc. Then I thought someone might have already built it, so I should ask around if there are any good user management libraries out there, or any advice on what I should consider in making one.
#2

[eluser]TheFuzzy0ne[/eluser]
Are you sure you can keep a session in memory (or are you referring to MemCache or APC?)? I've never heard of this before. Normally it's stored on the server's hard drive (and only put into RAM when the user maes a request to the server), and it's referenced either from a cookie, or via an argument in the URL.

I doubt you'll find a library like you're after, since permissions are totally different to sessions. I would suggest using the sessions library, and set the users permissions when they login. You can go the extra mile if you want and check their permissions upon each request, in case you have changed their permissions while they were logged in, but it's up to you whether or not you need to implement this.
#3

[eluser]merik[/eluser]
You are right. What I meant to describe was the way normal PHP session works: it is stored in files and loaded to memory on demand.

Session library is not what I want, because it exposes user data into the cookie, and because it keeps you logged after you close the browser window.

But what I want to do is a centralized way to control permissions. Does CI have a permissions library?
#4

[eluser]TheFuzzy0ne[/eluser]
[quote author="merik" date="1362688452"]
Session library is not what I want, because it exposes user data into the cookie, and because it keeps you logged after you close the browser window.[/quote]

It does??

You can encrypt your cookies, or store session data in the database. That's exactly what I do. It keeps cookies lean, and keeps sensitive data out/obscured, and it overcomes the cookie size limit, too.

You can also set them to expire once the browser is closed. It can all be done in the ./application/config/config.php file.

[quote author="merik" date="1362688452"]
But what I want to do is a centralized way to control permissions. Does CI have a permissions library?[/quote]

No, it doesn't. But it should be pretty simple to put one together. It depends on how much functionality you need.
#5

[eluser]merik[/eluser]
[quote author="TheFuzzy0ne" date="1362690028"]
You can encrypt your cookies, or store session data in the database.
[/quote]

Is it possible to not use a DB? Just use the usual file based system that PHP does by default?

[quote author="TheFuzzy0ne" date="1362690028"]
No, it doesn't. But it should be pretty simple to put one together. It depends on how much functionality you need.[/quote]

I just wanted not to reinvent the wheel. In fact, I created my own user library since I opened this thread.
#6

[eluser]TheFuzzy0ne[/eluser]
[quote author="merik" date="1362701849"]
Is it possible to not use a DB? Just use the usual file based system that PHP does by default?
[/quote]

Yes. Just don't use the CodeIgniter Sessions class, and use native PHP Sessions instead.

Why don't you want to use the database?




Theme © iAndrew 2016 - Forum software by © MyBB