Reply to Re: checking database or session?

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация