ninjazin has asked for the wisdom of the Perl Monks concerning the following question:
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");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI Session Not Working
by golux (Chaplain) on Mar 22, 2015 at 17:24 UTC | |
|
Re: CGI Session Not Working
by Your Mother (Archbishop) on Mar 22, 2015 at 16:54 UTC | |
by choroba (Cardinal) on Mar 22, 2015 at 17:29 UTC | |
by Your Mother (Archbishop) on Mar 22, 2015 at 17:54 UTC | |
by ninjazin (Initiate) on Mar 22, 2015 at 18:29 UTC | |
|
Re: CGI Session Not Working
by chacham (Prior) on Mar 23, 2015 at 15:20 UTC | |
|
Re: CGI Session Not Working
by anonymized user 468275 (Curate) on Mar 25, 2015 at 18:22 UTC |