RE: [PHP] User authentication
| From: | Dan Joseph | Date: | Thu, 02 Oct 2003 15:31:55 +0000 |
| Subject: | RE: [PHP] User authentication | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164763@lists.php.net to get a copy of this message | ||
Hi,
> That's great help and exactly what I'd like to do timeouts and all. I
> now just need to figure out he mechanics of the code for it and get a
> better understanding of sessions. I'm thinking in the user table I'll
> have a bunch of boolean fields for different permissions that apply to
> different pages etc. To keep it simple at first I'll just have two
> permissions "read only" and "edit". Read only users will not be allowed
> to access pages where they can edit data.
>
> How do you check for idle? I suppose there is a built in variable that
> you check against the value in the table. How do I pull up or refer to
> session variables?
Sessions are stored in the $_SESSION array. A simple check would be:
if ($_SESSION['user_id'] == "" || is_null($_SESSION['user_id']))
redirect_to_index_function();
Where 'user_id' is, that would be the name of the session you created.
Just insert that at the top of each page (might be best suited in an include
file).
-Dan Joseph