Presentation is loading. Please wait.

Presentation is loading. Please wait.

Perl – Cookie Setting #!/usr/bin/perl use CGI qw( :standard ); $cookie1 = cookie( -name=>'colour', -value=>'green', -path=>'/' ); print header( -cookie=>$cookie1.

Similar presentations


Presentation on theme: "Perl – Cookie Setting #!/usr/bin/perl use CGI qw( :standard ); $cookie1 = cookie( -name=>'colour', -value=>'green', -path=>'/' ); print header( -cookie=>$cookie1."— Presentation transcript:

1 Perl – Cookie Setting #!/usr/bin/perl use CGI qw( :standard ); $cookie1 = cookie( -name=>'colour', -value=>'green', -path=>'/' ); print header( -cookie=>$cookie1 ); print start_html(); print end_html();

2 Perl – Cookie Getting #!/usr/bin/perl use CGI qw( :standard ); print header(); print start_html(); print cookie(-name=>'colour'); print end_html();

3 Perl – Other Cookie Attributes -domain – usual domain value -expires – usual expiry date – also supports relative times such as: +30s# 30 seconds from now +10m# 10 minutes from now +27h# 27 hours from now +10d# 10 days from now +7M# 7 months from now +3y# 3 years from now

4 Perl – Setting Multiple Cookies header( -cookie=>[$cook1,$cook2,$cook3] );

5 Python – Cookie Setting #!/usr/bin/python2 import Cookie C = Cookie.SmartCookie() C["food"] = "apple" C["food"]["path"] = "/" print C print "Content-type: text/html\n"...

6 Python – Cookie Getting #!/usr/bin/python2 import Cookie import os C = Cookie.SmartCookie() C.load( os.environ[ "HTTP_COOKIE" ] ) print "Content-type: text/plain\n" for item in C.keys(): print item, C[item].value

7 PHP – Setting Cookies boolean setcookie ( string name [, string value [, int expire [, string path [, string domain [, int secure]]]]])

8 PHP – Setting Cookies ● expire – integer in UNIX time as returned by the time() funciton – use 0 to skip the setting of the time value boolean setcookie ( string name [, string value [, int expire [, string path [, string domain [, int secure]]]]])

9 PHP – Getting Cookies ● stored in the $_COOKIE associative array ● echo $_COOKIE[“food”]; ● also included in $_REQUEST associative array

10 PHP – Output Buffering.... [HTML output].... [HTML output]

11 Authorization/Authentication

12 Apache – Basic Authentication AuthType Basic AuthName "realm XYZ" AuthUserFile "D:/basic_passwd" Require valid-user

13 Basic Password File alice:$apr1$5s/.....$zxCiHf7tPO4.wVLbsEtfS1 bob:$apr1$zs/.....$j3XDKzq8L5DbuhC5whhE/. carol:$apr1$Nt/.....$lfidtsB700BGwyBbxzhU5/ ted:$apr1$dt/.....$L.RGB9f9g7h2ofdx3mrxK0 Adding new users: $ htpasswd /path/to/basic_pwd newuser

14 Apache – Digest Authentication AuthType Digest AuthName "realm ABC” AuthDigestDomain /S123/ AuthDigestProvider file AuthUserFile ”/home/xyz/digestpw" Require valid-user

15 Digest Password File alice:realm ABC:37803f542145fabf74e05f1ee3b53dfd bob:realm ABC:ac4399b97250c72c36635a1f8d31a6d1 carol:realm ABC:2fd092517717088846a80e1daffe3576 ted:realm ABC:a64f8dfe7035ad84e32fb0feff39eed6 Adding new users: $ htdigest /path/to/digest_pwd realm newuser

16 Authentication Summary ● Basic – very insecure; widely supported in most browsers ● Digest – more secure; not as widely supported in browsers


Download ppt "Perl – Cookie Setting #!/usr/bin/perl use CGI qw( :standard ); $cookie1 = cookie( -name=>'colour', -value=>'green', -path=>'/' ); print header( -cookie=>$cookie1."

Similar presentations


Ads by Google