10.07.2015 Views

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 11 ■ DEVELOPMENT WITH MOD_PERL 223Listing 11-11. Sending a Cookie with Apache::Cookieuse Apache::Cookie;use strict;my $r = shift;my $cookie = Apache::Cookie->new($r,-name => "testcookie",-value => "testvalue",-path => "/",);$cookie->bake();$r->send_http_header();The values for the cookie in the example are set via the new() method, and the bake()method is called <strong>to</strong> actually send the cookie <strong>to</strong> the client. The cookie arriving at the browseris shown in Figure 11-15.Figure 11-15. The cookie set with Apache::CookieYou can also set or change the parameter values for cookies by calling each individualmethod prior <strong>to</strong> calling bake(). For example, the program in Listing 11-12 (Securecookie.cgi)sets the secure flag on the cookie after it has already been instantiated with the new() method.Listing 11-12. Sending a Secure Cookieuse Apache::Cookie;use strict;my $r = shift;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!