To com o seguinte problema, tem uma pagina em php que vai chamar uma outra pagina feita com jsp/java/javascript essa pagina em php tem uma sessao e o que eu queria era o seguinte essa pagina jsp soh deve ser exibida se a sessao estiver ativa. como faco isso?
vou colocar os codigos fontes php (nao fui eu quem fiz)
[code]<?
#inicilizando a sessao
session_start();
#Incluindo arquivos necessarios
include(“include/classes/Mysql.php”);
include(“include/classes/Usuario.php”);
#Instanciando o Objeto Mysql
$mysql = new Mysql();
$usr = new Usuario();
$usr->verificarUsuario($_SESSION[“autoriza”]);[/code]
esse codigo o cara colocou em todas as paginas para verificar se a sessao existe.
[code]<?
//------------------------------------------------
class Mysql {
//------------------------------------------------
/**
- Autor: Vinicius Gallafrio/BR - vgallafrio@madeinweb.com.br
- Date : 15/01/2002
- http://www.madeinweb.com.br
- Description: PHP Class for MySQL Connection
- EXAMPLES:
- SELECT
- include “class.mysql.php”;
- $mysql = New mysql(‘localhost’,‘root’,‘password’,‘database’,0);
- $mysql->query(“SELECT field FROM table”);
- if ($mysql->num_rows() > 0) {
-
while ($mysql->movenext()) {
-
echo $mysql->getfield("field");
-
}
- }
- INSERT
- include “class.mysql.php”;
- $mysql = New mysql(‘localhost’,‘root’,‘password’,‘database’,0);
- $mysql->query(“INSERT INTO table (field) values (‘value’)”);
- UPDATE
- include “class.mysql.php”;
- $mysql = New mysql(‘localhost’,‘root’,‘password’,‘database’,0);
- $mysql->query(“UPDATE table SET field=‘newvalue’ WHERE fieldID=1”);
- DELETE
- include “class.mysql.php”;
- $mysql = New mysql(‘localhost’,‘root’,‘password’,‘database’,0);
- $mysql->query(“DELETE FROM table WHERE fieldID=1”);
*/
/* public: connection parameters */
var $debug;
var $host;
var $database;
var $user;
var $password;
/* private: connection parameters */
var $conn;
var $rstemp;
var $record;
/**
* mysql::mysql()
* Constructor this class - define public connection parameters and
* call the connect method
*
* @param $host
* @param $user
* @param $password
* @param $database
*/
function Mysql () {
@$this->debug = $debug;
if ($this->debug) echo "\n\nDebug On <br>\n";
$this->host = "localhost";
$this->user = "root";
$this->password ="vertrigo";
$this->database = "agenda";
/**
* open connection
*/
$this->connect();
}
/**
* mysql::connect()
* Open connection with the server
*
* @return id da conexao
*/
function connect () {
/**
* Open connection
*/
if ($this->debug) echo "Connecting to $this->host <br>\n";
$this->conn = @mysql_pconnect($this->host,$this->user,$this->password)
or die("Connection to $server failed <br>\n");
/**
* Select to database
*/
if ($this->debug) echo "Selecting to $this->database <br>\n";
@mysql_select_db($this->database,$this->conn)
or die("Error:" . mysql_errno() . " : " . mysql_error() . "<br>\n");
return $this->conn;
}
/**
* mysql::query()
* Execute SQL
*
* @param $sql
* @return
*/
function query($sql) {
if ($this->debug) echo "Run SQL: $sql <br>\n\n";
$this->rstemp = @mysql_query($sql,$this->conn)
or die("Error:" . mysql_errno() . " : " . mysql_error() . "<br>\n");
return $this->rstemp;
}
/**
* mysql::num_rows()
* return number of records in current select
*
* @param $rstemp
* @return
*/
function num_rows() {
$num = @mysql_num_rows($this->rstemp);
if ($this->debug) echo "$num records returneds <br>\n\n";
return $num;
}
/**
* mysql::movenext()
* fetch next record in result
*
* @return
*/
function movenext(){
if ($this->debug) echo "Fetching next record ... ";
$this->record = @mysql_fetch_array($this->rstemp);
$status = is_array($this->record);
if ($this->debug && $status) echo "OK <br>\n\n";
elseif ($this->debug) echo "EOF <br>\n\n";
return($status);
}
/**
* mysql::getfield()
* get field value from the current record
*
* @param $field
* @return
*/
function getfield($field){
if ($this->debug) {
echo "Obtendo $field ... ";
//this resource require PHP 4.1 or righter
if (phpversion() >= 4.1) {
if (array_key_exists($field,$this->record)) echo "OK <br>\n\n";
else echo "Não encontrado <br>\n\n";
} else echo " <br>\n\n";
}
return($this->record[$field]);
}
/**
* mysql::lastid()
* pega o último id inserido
*
* @return
*/
function lastid() {
$lastid = mysql_insert_id($this->conn);
return ($lastid);
}
}
?>
[/code]
[code]<?
class Usuario extends Mysql {
function verificarUsuario ($usr){
parent::query("SELECT * FROM TB_USUARIO_USR USR WHERE USR.NOM_LOGIN_USR = '$usr'");
if (!parent::num_rows() > 0) {
header ("Location: http://sistemas4.seplag.ce.gov.br/agenda/index.php");
exit;
}
}
}
?>[/code]
essas duas classes tao sendo importadas naquele outro codigo
[]'s