session include file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
theclay7
Forum Commoner
Posts: 50
Joined: Wed Feb 19, 2003 3:17 am

session include file

Post by theclay7 »

hi, i am going to write a session check include file to put it into pages that needed to be in logon mode. Therefore, I need to have an include file to check if the user is already logon.

how do i write this include file using session?

:roll:
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

So when someone logs on you put on a cookie so it remembers their username and password?

If so make a file called something like authcheck.php, include it into all your "protected" files and in it add something like:

Code: Select all

<?php
if (!$username == "username" && !$password =="password") {
header("location: login.php");
}
else {
// No probs! You're logged in!
}
?>
Hope this helps!
theclay7
Forum Commoner
Posts: 50
Joined: Wed Feb 19, 2003 3:17 am

Post by theclay7 »

thanks...
but how does this page get the parameter username and passwd???

is there a way that I can use Session control?

say if i want to view 1.php to 2.php, but the content of 2.php is restricted to logon user...how do i keep his session and use session?

i am new to session...
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

What do you have on your login page?
Post Reply