Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: How to ensure that cookies are always sent via SSL

by bigup401 (Pilgrim)
on May 21, 2015 at 12:19 UTC ( [id://1127343]=note: print w/replies, xml ) Need Help??


in reply to Re: How to ensure that cookies are always sent via SSL
in thread ssl cookies

why i get this error. from home.pl works, bt when i redirect to wel.pl with cookie i get this error

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href="wel.pl">here</a>.</p> <hr> <address>Apache/2.2.3 (CentOS) Server at #hostname Port 443</address> </body></html>

this is my cookie code

use CGI; $page = 'wel.pl'; my $cookie = $cgi->cookie(-name => 'welcome', -value => $name, -expire +s=> '+1m'); print $cgi->redirect(-location => $page, -cookie => $cookie +);

Replies are listed 'Best First'.
Re^3: How to ensure that cookies are always sent via SSL
by hippo (Bishop) on May 21, 2015 at 13:15 UTC

    That is not an error. It is precisely what you asked for.

      i get this wicked response! i thought it was my server, bt i fixed everything. and working. with print "Location: $url"; redirect works well bt cant work with $q->redirect and send cookie out

      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href="page">here</a>.</p> <hr> <address>Apache/2.2.3 (CentOS) Server at #hostname Port 80</address> </body></html>

      my problem similar to this

      #!/usr/bin/perl use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; my $q = new CGI; if ($q->param("Login")) { my $Password = param('Password'); if (!$Password) { print "Please Enter the Password"; } else { my $dbh = DBI->connect( "dbi:SQLite:DEVICE.db", "", "", { RaiseError => 1, AutoCommit => 1 } ); my $cookie = $q->cookie(-name => 'welcome', -value => 'name', + -expires=> '+1m'); my $sth = $dbh->prepare("select * from Settings where Password + = ?"); $sth->execute($Password); if (my $pass = $sth->fetchrow_hashref) { $page = 'wel.pl'; print $q->redirect(-location => $page, -cookie => $cookie) +; } else { print "Invalid Password"; } $dbh->disconnect; } } print "Content-Type: text/html\n\n"; print <<END1; <HTML> <HEAD> <TITLE> </TITLE> </HEAD> <body> <form NAME="login" METHOD="POST"> <input type="hidden" name="submit" value="Submit"> <TABLE align="center" bgcolor=#B0C4DE> <TR> <TD> Enter The Password And Click Login</TD> </TR> <TR></TR> <TR></TR> <TR></TR> <TR></TR> <TR></TR> <TR> <TD><b>PASSWORD</b> :<input type="password" name=" +Password" size="20" maxlength="15" /></TD> </TR> <TR></TR> <TR></TR> <TR></TR> <TR></TR> <TR></TR> <TR> <TR> <TD align="center" colspan="2"> <input type="submit" name="Login" value="Login +"> <input type="reset" name="submit" value="Cance +l"> </TD> </TR> </TABLE> </FORM> </BODY> </HTML> END1

        Congratulations on getting it working.

        What was the problem?

      i called it error coz. it was working fine on my platform, same webserver version. bt when i took it online. i got that response. is there anyway to fix it?

Re^3: How to ensure that cookies are always sent via SSL
by Your Mother (Archbishop) on May 21, 2015 at 19:38 UTC

    I am a broken record on this but–

    $page = 'wel.pl';

    –is wrong even though it will work in nearly every situation. Redirect URLs RFC:MUST be absolute, not relative. Most clients in Christendom support relative but it’s still a bad practice. Also, please use strict; and declare your variables my $page… Also not absolutely necessary but will save you tons of grief.

        What! Damnit… Thanks for the link.

      Thanks monk bt i was already fixed the whole problem by going through this

      https://perl.apache.org/docs/2.0/user/coding/cooking.html

      my problem was cookies, so i had to use apache2::cookie because am using Apache web server on centos. so some functions were limited. i don't know why nginx is so easy for Perl, and Apache become so hard for Perl

        my problem was cookies, so i had to use apache2::cookie because am using Apache web server on centos. so some functions were limited. i don't know why nginx is so easy for Perl, and Apache become so hard for Perl

        A poor workman blames his tools

        You're using CGI.pm, using it poorly, and now you're manually adding Apache2 API into the the mix -- disaster

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1127343]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-18 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found