Re: User authentication
| From: | Curt Zirzow | Date: | Thu, 02 Oct 2003 15:29:58 +0000 |
| Subject: | Re: User authentication | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164769@lists.php.net to get a copy of this message | ||
* Thus wrote Dan Joseph (djoseph@duhq.us):
> 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).
I would suggest a require(), that way if the file can't be included
the script will fail at the require.
Curt
--
"I used to think I was indecisive, but now I'm not so sure."