By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,409 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,409 IT Pros & Developers. It's quick & easy.

Track user usage, session tracking or cookies?

P: n/a
I want to prevent non-registered users to view a page in my website,
For example, when a non-registered user clicks the history page, the
website site refuses to go there since he is not registered.

what is the best way to do it? And how to identify a user has already
logged in when he click the history page?

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I use sessions to manage users once they log in. Here is an article
about managing users with mysql and sessions:
http://www.sitepoint.com/article/use...sessions-mysql

Once a user logs in, declare a session:

session_start();

Declare a session variable saying that the person is logged in:

$_SESSION['login'] = true;

When a user tries to get to a user-only page, check the session
variable to see if the person is a logged-in registered user:

if ($_SESSION['login'] == true)
{
Let user request the page;
}
else
{
Send user to the registration page;
}

Nick Mudge
www.democranet.com

Jul 17 '05 #2

P: n/a
Sessions use cookies anyways usually -- so use sessions.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.