profile.pl (where i need session data)#!/usr/bin/perl print "Content-type: text/html\n\n"; require 'learn/db_connect.pl'; use CGI; use CGI::Session qw(); use DBI; use warnings; use Digest::SHA qw(hmac_sha512_hex); $q = new CGI; my $cgi = new CGI; if($q->request_method eq "POST"){ my $uname = $q->param('uname'); my $pass = $q->param('pass'); if(defined($uname) && $uname ne ""){ if(defined($pass) && $pass ne ""){ my $pass_hash = hmac_sha512_hex($pass); my $dbh = connectDB(); my $sth = $dbh->prepare("SELECT count(id) as counted FROM +perl_users WHERE `username` = ? AND `password` = ?"); $sth->execute($uname, $pass_hash); my $ref = $sth->fetchrow_hashref(); if($ref->{'counted'} == 1){ my $sql001 = $dbh->prepare("SELECT * FROM perl_users W +HERE `username` = ? AND `password` = ?"); $sql001->execute($uname, $pass_hash); my $result = $sql001->fetchrow_hashref(); $user_id = $result->{'id'}; $username = $result->{'username'}; my $s = CGI::Session->new; $s->param("user_id" => $user_id); my $id = $s->id; print "<script>window.location.href = 'profile.pl?toke +n=".$id."';</script>"; }else{ print "<script>window.location.href = 'index.pl?error= +Invalid Username OR Password.';</script>"; } }else{ print "<script>window.location.href = 'index.pl?error=plea +se fill all fields';</script>"; } }else{ print "<script>window.location.href = 'index.pl?error=please f +ill all fields';</script>"; } }else{ print "<script>window.location.href = 'index.pl';</script>"; }
Whats wrong i'm doing here ? I have tried lots of things with CGI:Session and still no luck, i'm stuck with this since last two days and feeling dumb now as i'm not new to programming. Any gelp will be highly appreciated. Thanks.#!/usr/bin/perl print "Content-type: text/html\n\n"; use CGI; use CGI::Session qw(); use DBI; use warnings; $get = new CGI; $token = $get->param('token'); my $s = CGI::Session->new($token); print $s->param("user_id");
In reply to CGI Session Not Working by ninjazin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |