The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Helix::Core::CGI - common gateway interface functions for Helix Framework.

SYNOPSIS

    use Helix::Core::CGI;

DESCRIPTION

The Helix::Core::CGI class provides standart CGI functions - GET/POST requests parsing, cookies & session handling. It's more comfortable and fast replacement of old CGI package.

METHODS

new()

Class constructor. Creates an object and calls the initialization function.

_init()

Class initialization. Parses input data - GET data, POST data, cookies and session variables.

decode_string($string)

Decodes an url-encoded $string.

get($name)

Returns a value of the GET parameter. If $name of variable is not given, returns a hashref with all GET parameters.

post($name)

Returns a value of the POST parameter. If $name of variable is not given, returns a hashref with all POST parameters.

get_file($name)

Returns a hashref with uploaded file data:

  • name

    Uploaded file name.

  • tmp

    Path to temporary file, where uploaded file contents are stored. This file is automatically deleted during Helix::Core::CGI object destruction, so you don't need to care about this.

  • ext

    Uploaded file extension.

If $name of parameter is not given, returns a hashref with all uploaded files.

receive_file($name)

Returns contents of the uploaded file. $name - name of upload variable.

get_param($name)

Returns a value of the GET or POST parameter with the given $name. If variable $name exists both in GET and POST requests, value will be taken from first.

get_cookie($name)

Returns a cookie value.

set_cookie($name, $value, $expires, $path, $domain)

Sets a cookie. $expires - is a number of seconds in which the cookie will be expired.

generate_string($len)

Returns a randomly-generated string with. $len - length of the string to be generated. If $len is not specified, 32-character string will be generated.

init_session()

Initialize user session. Generates a magic session ID and sets a cookie with this value to user.

destroy_session()

Destroys the session, if any.

set_session($key, $value)

Sets session parameter $key with the given $value.

get_session($key)

Returns $key session parameter value.

is_header_sent()

Checks if HTTP header is already sent. Returns 1 or 0.

add_header($header)

Adds user-defined header string $header.

send_header()

Sends HTTP header to browser.

SEE ALSO

Helix, CGI

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Anton Belousov, <abel@cpan.org>

COPYRIGHT

Copyright (c) 2009, Atma 7, http://www.atma7.com