Re: Need help with Session's in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is how i use session in my php application

(1) my login page starts the session then register the
following code variables:
 
<?php
session_start();
...
...
...
if ($loginFoundUser) {

$username = mysql_result($result,0,'username');
		
$_SESSION['username'] = $username; 

}

(2) Then I have a file named "sesscontrol.php" with
the following codes:

<?php
session_start();
header("Cache-control: private"); // IE 6 Fix. 
@$username = $_SESSION['username'];


if(!$username){
	echo ("Session Expired, <a href=\"../ReLogin.php\">
Click Here<a> to Re-Login");
	echo '<meta http-equiv = "refresh" content ="0; 
	url = ../ReLogin.php">';
	exit;
}
?>

(3) Now in each file i want to control access i put
the following codes:

<?php 
require_once('sesscontrol.php');

...

This is quite enough

Lungo


--- Seshasayee Madaboosi <smadaboosi@xxxxxxxxx> wrote:

> Try phplib, I don't know if this is
> maintained(updated), but you can get a whole lot of
> things from there.
>  
> Sesh Madaboosi CISA, CSSA
> Coherent Business Solutions LLC
> www.cobizsolutions.com
> 
> 
> Sher <sha_sher@xxxxxxxxx> wrote:
> Hi 
> 
> I've just started doing programming in PHP.
> i want to know how can i maintain session in
> different pages on my site.
> 
> i want to restrict people from accessing some pages
> on my site. and
> only registered person can access that site.
> 
> i want to know how can i create and maintain session
> objects, and also
> how to track session on different pages on my site.
> and through that
> how can i restrict users.
> 
> At the moment i have created the 
> register page( for anyone to register)
> login page to login to the site
> 
> 
> 
> i m using 
> PHP Version 5.0.4 
> MySQL server 4.1 
> Running on windows 2000 server with IIS 5.0
> 
> any help will be appreciated.
> Thank you
> Shakeeb

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12h7kdd1o/M=362335.6886445.7839731.1510227/D=groups/S=1705006764:TM/Y=YAHOO/EXP=1124736790/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/";>In low income neighborhoods, 84% do not own computers. At Network for Good, help bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~-> 

PHP Data object relational mapping generator - http://www.meta-language.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux