|
Posted by Jasen Betts on 02/11/06 02:11
On 2006-02-10, Mike <mike@mjfcadsolutions.co.uk> wrote:
> I'm developing a site that a user registers, logs in and for some
> pages, has to subscribe.
>
> Basically, the user registers and then when they log in I set a session
> say AUTH=yes.
>
> Then every page the user goes to I can check the AUTH session and if
> yes then display the page else request a login.
>
> Now I will have a flag in the database that when a user subscribes the
> field PAID=yes.
>
> What would be the best way to check the user has paid at the top of
> every page that requires a subscription.
>
> I have thought of 2..
>
> 1) When the user logs in and the AUTH=yes is set, the database is also
> checked for the PAID field and if PAID=yes then set a session say
> USERHASPAID=yes. Then on ever page required I just check the session
> USERHASPAID.
>
> 2) When the user logs in and AUTH=yes is set, the users unique id is
> also stored to a session. Then on every page requiring subscription
> the database is searched for the users unique id and PAID=yes.
>
> I know they both will work but I was just wondering which would be the
> prefered method.
if you put it in $_SESSION[] it means less database traffic, but if it changes
in the database during the session you need to update $_SESSION[] too
--
Bye.
Jasen
[Back to original message]
|