I've created a web application page with login and session login

basically a

<?php session_start() ?>

do I really need to put this code on every page of my php ?
because session login only active on the first page after I do login..

Anyone.. Help me on this.. Thanks

If you want to check that session's value on other pages, i.e. if user is logged in or not, then you have to add it on all top of page.

because after I login..when I try to click on the different page...I'm out of the session login ... that's the problem ..
So basically adding on every page.. will solve the problem yea ?

if I may know.. how to add cookies to remember the session everytime going back to the first page ? if I may know...

Do what I do, I created a "global.php" page and I include it at the top of every page. At the very top of "global.php" I have "session_start();" and below that I have all the variables I want to use, that way I can check if the user is logged in or not on every page, and use the variables I have set.

any sample or references ? Sorry I'm bit new with this .. :)

When user login you can set user's id in session.

$_SESSION['sess_userId'] = 12; // whatever id

Below is the function check if user is login or not.

function isUserLogin()
{
    if(!isset($_SESSION['sess_userId']))
    {       
        header("location:login.php");
        exit;
    }   
}

Now call this functionisUserLogin(); on top of page where you want guest restriction.
Not include in global.php otherwise all page will be asked for login.