开发者

Question about user system, specifically sessions with PHP

I was reading this article: http://www.devarticles.com/c/a/PHP/Creating-a-Membership-System/2/

I am not sure if I understand sessions properly. Do I hav开发者_Go百科e to start a session for each member protected page? or do I just have to create one session and check if the user is in a session on each and evey page? how would I do that? Examples apprecited! :)


you (usally) don't really create a session. You just session_start(); on beginning of EVERY page and assign data to $_SESSION.

EDIT:

PHP sessions are not really "sessions", they're just containers of data.

When users logs in, you assign to session for example:

$_SESSION['loggedin'] = '1';

And on every page you check that:

if($_SESSION['loggedin'] !== '1')
{
   exit;
}

// your stuff

very simple.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜