views:

26

answers:

2

Hi all:

Have to say I wish I could implement server-side persistence (i.e., session-based and/or database-based user state persistence), but unfortunately my uni's server has limited resources provided and it is really hard to implemented a Perl based session solution (CGI::Session and Apache::Session not installed, dated Perl version, dated Perl environment, etc).

So I guess my last resort would be with some client-side persistence approach, most preferably Javascript-based, should be not a solution only for Flash or HTML5.

I just did a little bit research online for this unfamiliar topic and found these:

Pablotron: PersistJS Dojox.storage YUI 2 Storage Utility

I wonder which would give me the simplest way of managing user session, basically, I reckon I only need to manage the user session Id, and maybe several other important keys; for the rest of data, I will just put them in database.

This is purely for uni work so I am not considering of having a really thorough solution. I know there must be certain drawbacks for this, such as security risks, but... please just confirm me whether this is a feasible and practical way.

Thanks for any suggestion in advance!

+1  A: 

I would honestly recommend you using apache's htaccess/htpasswd for this. It handles sessions in a safe way and you can grant access to multiple users and/or groups. The downside is that accounts creation and passwords (re)assignation has to be manual. Of course the benefits (one being 0 development time) greatly overcomes the downsides.

Ben
@Ben: yeah I am also considering http basic authentication on Apache. One thing I am not sure is, say, John Smith logged himself in, how could my other pages tell which user is this? Users in certain groups can access certain regions on site, but I am not sure how to map to the individual username/userid
Michael Mao
@Michael Mao htaccess works per directory, once you're logged in you can access anything in that directory and once you close the browser you log out. If memory serves me right you can use `$_SERVER['PHP_AUTH_USER']` to get the user name. Be sure to check out the `$_SERVER['PHP_AUTH_xxx']` variables in the PHP documentation.
Ben
@Ben: That's right, in case of Perl, that's $ENV{REMOTE_USER} :)
Michael Mao
+1  A: 

You just need to store a session id and a few other keys on the client side? Isn't that exactly what cookies are designed for?

morgancodes