CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
ASP x Perlscript - Cookies are not Responsed and returns no errors

 



web2solutions
Novice

Sep 18, 2010, 8:54 PM

Post #1 of 2 (739 views)
ASP x Perlscript - Cookies are not Responsed and returns no errors Can't Post

When I access http://www.guarapari.etc.br/extranet/perl/desktop2/source/login/login.asp?UserName=eduardo&Password=demo

It runs a subroutine that returns a Json response and writes a cookie with some user data.

But the cookies are not been writed when a call the subroutine, but when I write the cookie on other place of the script, it works.

look:
login.asp

Code
<%@ LANGUAGE="PerlScript" CODEPAGE="65001"%> 
<!--#include file="../desktopnew.asp"-->
<%


#$usuario=GetFormValue("UserName");
#$senha=GetFormValue("Password");

$usuario=$Request->QueryString("UserName")->item();
$senha=$Request->QueryString("Password")->item();

print Desktop->login($usuario, $senha);

%>



desktopnew.asp

Code
<!--#include file="funcoes.asp"--> 
<%
{package Desktop;

$username="xxxxx";
$password="xxxxxx";
$conexaoDBI = DBI->connect("dbi:PgPP:dbname=romaimoveis;host=pgsql.web2.eti.br;port=5432",$username, $password);

sub esta_logado {

}

sub login {
$usuario = $_[1];
$senha = $_[2];
$json = "";
if(not defined($usuario) or not length($usuario))
{
$json = "{errors:[{id:'user', msg:'Campo obrigatório'}]}";
}
elsif(not defined($usuario) or not length($usuario))
{
$json = "{errors:[{id:'pass', msg:'Campo obrigatório'}]}";
}else
{
$sql="select login from tbl_usuarios WHERE login='$usuario';";
my $dbh = $conexaoDBI->prepare($sql);
$dbh->execute();
if (my $registro = $dbh->fetchrow_hashref())
{
$criptsenha = $senha;
$sql="select login,senha from tbl_usuarios WHERE login='$usuario' AND senha='$criptsenha';";
my $dbh1 = $conexaoDBI->prepare($sql);
$dbh1->execute();
if (my $registro1 = $dbh1->fetchrow_hashref())
{
$sql="select id,tipo,login,nome,senha,permissoes from tbl_usuarios WHERE login='$usuario' AND senha='$criptsenha';";
my $dbh2 = $conexaoDBI->prepare($sql);
$dbh2->execute();
if (my $registro2 = $dbh2->fetchrow_hashref())
{
my $usuarioid = $registro2->{'id'};
my $usuarionome = $registro2->{'nome'};
my $usuariologin = $registro2->{'login'};
my $usuariosenha = $registro2->{'senha'};
my $usuariotipo = $registro2->{'tipo'};
my $usuariopermissoes = $registro2->{'permissoes'};
## Gera cookie de login
gerenciacookie->geracookie(true, $usuarioid, $usuarionome, $usuariologin, $usuariosenha, $usuariotipo, $usuariopermissoes);
## retorna json para a RIA
$json = "{success:true, key:'', username:'$usuariologin', name:'$usuarionome', type:'$usuariotipo'}";
}else
{
$json = "{errors:[{id:'user', msg:'Falha ao efetuar login'}]}";
}
$dbh2->finish;
}else
{
$json = "{errors:[{id:'pass', msg:'Senha incorreta'}]}";
}
$dbh1->finish;
}else
{
$json = "{errors:[{id:'user', msg:'Usuario nao encontrado'}]}";
}
$dbh->finish;
}
return $json;
}

sub logout {

}

}

{package gerenciacookie;

sub geracookie{
$booleano = $_[1];
$id = $_[2];
$nome = $_[3];
$login = $_[4];
$senha = $_[5];
$tipo = $_[6];
$permissoes = $_[7];
$Response->{Cookies}{wdesk}{logado} = $booleano;
$Response->{Cookies}{wdesk}{id} = $usuarioid;
$Response->{Cookies}{wdesk}{nome} = $usuarionome;
$Response->{Cookies}{wdesk}{login} = $usuariologin;
$Response->{Cookies}{wdesk}{pass} = $usuariosenha;
$Response->{Cookies}{wdesk}{tipo} = $usuariotipo;
$Response->{Cookies}{wdesk}{logon} = "";
$Response->{Cookies}{wdesk}{permissoes} = $usuariopermissoes;
}
}

$Response->{Cookies}{nome}{chave} = "value";
print $Request->{Cookies}{nome}{chave};
print $Request->{Cookies}{wdesk}{nome};
%>



(This post was edited by web2solutions on Sep 18, 2010, 8:56 PM)


web2solutions
Novice

Sep 19, 2010, 7:24 AM

Post #2 of 2 (731 views)
Re: [web2solutions] ASP x Perlscript - Cookies are not Responsed and returns no errors [In reply to] Can't Post

??

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives