跟踪我网站上的用户[关闭]

I Know that this might be a very silly question to ask, but please keep in mind that this is my first project in web development and programming
I'm designing a CV maker website
I've done this interface using the help of a predefined template: and once the user is logged in, I'm redirecting is to another page myResume.php where he has to enter his info and so, here is the interface : . Now comes my question: How I'm supposed to track the user after he logs in? I mean how can I make sure that no one sees this page unless he logged in first ? Using my design, anyone can see the myResume page by using the specific URL, example : http://www.example.com/myResume.php
Reformulation, Is it possible to restrict the redirection to myResume.php to only from the login.php file ?
Thank you

I just did this like 2 days ago for a site i'm creating.

So what you want to do is set up session variables and check to see if they are there or not. I assume you have the login functionallity working, Where it checks the database to see if the user name and password match. If it does, you send them to the myResume.php.

The next step under login.php would be to set up a $_SESSION['user_id'] variable in php. This matches the session of a user to a serverside session. This variable is help on the server side with an access key stored in local cookies to match the session to the user. What is a Session?

The next thing you will want to do is add an if and header to every file on your site that should only be allowed access to logged in users.

session_start();
if(empty($_SESSION['user_id'])){
    header('Location: login.php');
}

If you want to log out you do something like this. You send them to a logout.php and in the logout.php file you simple have this statement.

session_start();
session_destroy();
header('location: login.php');

you have to allways start your session on each page before you can, use, set, destroy session variables.

The answer is the session: PHP manual on sessions

It lets you store information that your scripts can access as your user moves from page to page.

Have a look at tiztag tutorial on sessions or a sitepoint tutorial on sessions

hth