|
Posted by d on 10/10/43 11:39
"Mike" <mike@mjfcadsolutions.co.uk> wrote in message
news:1139561789.818227.232850@g44g2000cwa.googlegroups.com...
> 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.
>
> Thanks
>
> Mike
The first option is the best way, as puts less work on the database. It
does have one drawback, though, that the database is only checked when the
user logs in and not on every page access, so if for some reason the PAID
field is set to "NO" during the session, the session will still report that
the user has paid up. Apart from that, it's definitely the better way to go
:)
dave
Navigation:
[Reply to this message]
|