Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: basic login

by Anonymous Monk
on Apr 14, 2017 at 15:02 UTC ( [id://1187937]=note: print w/replies, xml ) Need Help??


in reply to basic login

If you're determined to do this on your own, it's going to be something like this:
if ($usr eq 'admin' && $pwd eq 'admin') { $cookie = ...; #inside content print "Content-Type: text/html\r\n"; print "Set-Cookie: login="$cookie"\r\n\r\n"; ... }
The client will send a Cookie header on subsequent requests. You have a lot of choices about what exactly to put in $cookie. You might use something like this:
my $cipher = Crypt::CBC->new(-key=>$secret_key, -cipher => 'Rijndael') +; my $cookie = MIME::Base64::encode_base64($cipher->encrypt("$usr:$pwd") +, '');
..assuming the user name doesn't include colons.

Replies are listed 'Best First'.
Re^2: basic login
by bigup401 (Pilgrim) on Apr 14, 2017 at 15:59 UTC

    am not sure it can work this way. and yes i tried it and fail

      To the ignorant or those in conventional industries, your recent failure may seem like a failure. But we in this Monastery all know that failures just like this one are really stepping stones. What those in dying business sectors call failure, we in tech know to be pre-greatness.
      If you want useful answers, you need to give us more information. What does "fail" mean? Did it produce an error message like "Can't locate Crypt/CBC.pm in @INC"? That's easy to fix by installing a module. Since you said elsewhere that you have something working now, I'm not going to worry about this any more. But please, in the future, try to be more specific!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found