Apache-ASP
view release on metacpan or search on metacpan
site/objects.html view on Meta::CPAN
them, directly:
<font face="courier new" size=3><pre>
$data = $Session->{complex}{data}; # Read ok.
$Session->{complex}{data} = $data; # Write NOT ok.
$Session->{complex} = {data => $data}; # Write ok, all at once.
</pre></font>Please see MLDBM for more information on this topic.
$Session can also be used for the following methods and properties:</font>
<p>
<a name=%24Session-%3E%7BCa919a318></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Session->{CodePage}</b></font>
<font face="courier new" size=3><pre>
</pre></font>Not implemented. May never be until someone needs it.</font>
<p>
<a name=%24Session-%3E%7BL2343b3bf></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Session->{LCID}</b></font>
<font face="courier new" size=3><pre>
</pre></font>Not implemented. May never be until someone needs it.</font>
<p>
<a name=%24Session-%3E%7BS1049f4e8></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Session->{SessionID}</b></font>
<font face="courier new" size=3><pre>
</pre></font>SessionID property, returns the id for the current session,
which is exchanged between the client and the server as a cookie.</font>
<p>
<a name=%24Session-%3E%7BTf539b225></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Session->{Timeout} [= $minutes]</b></font>
<font face="courier new" size=3><pre>
</pre></font>Timeout property, if minutes is being assigned, sets this
default timeout for the user session, else returns
the current session timeout.
<font face="courier new" size=3><pre>
</pre></font>If a user session is inactive for the full
timeout, the session is destroyed by the system.
No one can access the session after it times out, and the system
garbage collects it eventually.</font>
<p>
<a name=%24Session-%3EAbc5f4cea0></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Session->Abandon()</b></font>
<font face="courier new" size=3><pre>
</pre></font>The abandon method times out the session immediately. All Session
data is cleared in the process, just as when any session times out.</font>
<p>
<a name=%24Session-%3ELocc872f91></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Session->Lock() </b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension. If you are about to use $Session for many consecutive
reads or writes, you can improve performance by explicitly locking
$Session, and then unlocking, like:
<font face="courier new" size=3><pre>
$Session->Lock();
$Session->{count}++;
$Session->{count}++;
$Session->{count}++;
$Session->UnLock();
</pre></font>This sequence causes $Session to be locked and unlocked only
1 time, instead of the 6 times that it would be locked otherwise,
2 for each increment with one to read and one to write.
<font face="courier new" size=3><pre>
</pre></font>Because of flushing issues with SDBM_File and DB_File databases,
each lock actually ties fresh to the database, so the performance
savings here can be considerable.
<font face="courier new" size=3><pre>
</pre></font>Note that if you have SessionSerialize set, $Session is
already locked for each script invocation automatically, as if
you had called $Session->Lock() in Script_OnStart. Thus you
do not need to worry about $Session locking for performance.
Please read the section on SessionSerialize for more info.</font>
<p>
<a name=%24Session-%3EUnc1c1024f></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Session->UnLock()</b></font>
<font face="courier new" size=3><pre>
</pre></font>API Extension. Unlocks the $Session explicitly. If you do not call this,
$Session will be unlocked automatically at the end of the
script.</font>
<p>
<a name=%24Response%20Ob5268b3d4></a>
<font face=verdana><font class=title size=+0 color=#555555><b>$Response Object</b></font>
<font face="courier new" size=3><pre>
</pre></font>This object manages the output from the ASP Application and the
client web browser. It does not store state information like the
$Session object but does have a wide array of methods to call.</font>
<p>
<a name=%24Response-%3E%7B4a870234></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{BinaryRef}</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension. This is a perl reference to the buffered output of
the $Response object, and can be used in the Script_OnFlush
global.asa event to modify the buffered output at runtime
to apply global changes to scripts output without having to
modify all the scripts. These changes take place before
content is flushed to the client web browser.
<font face="courier new" size=3><pre>
sub Script_OnFlush {
my $ref = $Response->{BinaryRef};
$$ref =~ s/\s+/ /sg; # to strip extra white space
}
</pre></font>Check out the <a href=eg/global.asa>./site/eg/global.asa</a> for an example of its use.</font>
<p>
<a name=%24Response-%3E%7Ba1012197></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{Buffer}</b></font>
<font face="courier new" size=3><pre>
</pre></font>Default 1, when TRUE sends output from script to client only at
the end of processing the script. When 0, response is not buffered,
and client is sent output as output is generated by the script.</font>
<p>
<a name=%24Response-%3E%7B5be79ef4></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{CacheControl}</b></font>
<font face="courier new" size=3><pre>
</pre></font>Default "private", when set to public allows proxy servers to
cache the content. This setting controls the value set
in the HTTP header Cache-Control</font>
<p>
<a name=%24Response-%3E%7Bad3d9995></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{Charset}</b></font>
<font face="courier new" size=3><pre>
</pre></font>This member when set appends itself to the value of the Content-Type
HTTP header. If $Response->{Charset} = 'ISO-LATIN-1' is set, the
corresponding header would look like:
<font face="courier new" size=3><pre>
Content-Type: text/html; charset=ISO-LATIN-1
</pre></font>
<p>
<a name=%24Response-%3E%7Bd81fcef3></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{Clean} = 0-9;</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension. Set the Clean level, default 0, on a per script basis.
Clean of 1-9 compresses text/html output. Please see
site/objects.html view on Meta::CPAN
<a name=%24Request-%3EPa455879ca></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Request->Params($name)</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension. If RequestParams <a href=config.html><font size=-1 face=verdana><b>CONFIG</b></font></a> is set, the $Request->Params
object is created with combined contents of $Request->QueryString
and $Request->Form. This is for developer convenience simlar
to <a href=http://stein.cshl.org/WWW/software/CGI/cgi_docs.html><font size=-1 face=verdana><b>CGI.pm</b></font></a>'s param() method. Just like for $Response->Form,
one could create a nice alias like:
<font face="courier new" size=3><pre>
# in global.asa
use vars qw( $Params );
sub Script_OnStart {
$Params = $Request->Params;
}
</pre></font>
<p>
<a name=%24Request-%3EQu7330a0a3></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Request->QueryString($name)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Returns the value of the input of name $name used in a form
with GET method, or passed by appending a query string to the end of
a url as in <tt>http://localhost/?data=value.</tt>
If $name is not specified, returns a ref to a hash of all the query
string data.</font>
<p>
<a name=%24Request-%3ESe3a73f873></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Request->ServerVariables($name)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Returns the value of the server variable / environment variable
with name $name. If $name is not specified, returns a ref to
a hash of all the server / environment variables data. The following
would be a common use of this method:
<font face="courier new" size=3><pre>
$env = $Request->ServerVariables();
# %{$env} here would be equivalent to the cgi %ENV in perl.
</pre></font>
<p>
<a name=%24Application971dfe6c></a>
<font face=verdana><font class=title size=+0 color=#555555><b>$Application Object</b></font>
<font face="courier new" size=3><pre>
</pre></font>Like the $Session object, you may use the $Application object to
store data across the entire life of the application. Every
page in the ASP application always has access to this object.
So if you wanted to keep track of how many visitors there where
to the application during its lifetime, you might have a line
like this:
<font face="courier new" size=3><pre>
$Application->{num_users}++
</pre></font>The Lock and Unlock methods are used to prevent simultaneous
access to the $Application object.</font>
<p>
<a name=%24Application7d01ce04></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Application->Lock()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Locks the Application object for the life of the script, or until
UnLock() unlocks it, whichever comes first. When $Application
is locked, this guarantees that data being read and written to it
will not suddenly change on you between the reads and the writes.
<font face="courier new" size=3><pre>
</pre></font>This and the $Session object both lock automatically upon
every read and every write to ensure data integrity. This
lock is useful for concurrent access control purposes.
<font face="courier new" size=3><pre>
</pre></font>Be careful to not be too liberal with this, as you can quickly
create application bottlenecks with its improper use.</font>
<p>
<a name=%24Application2899ee54></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Application->UnLock()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Unlocks the $Application object. If already unlocked, does nothing.</font>
<p>
<a name=%24Applicationaeaabc29></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Application->GetSession($sess_id)</b></font>
<font face="courier new" size=3><pre>
</pre></font>This NON-PORTABLE API extension returns a user $Session given
a session id. This allows one to easily write a session manager if
session ids are stored in $Application during Session_OnStart, with
full access to these sessions for administrative purposes.
<font face="courier new" size=3><pre>
</pre></font>Be careful not to expose full session ids over the net, as they
could be used by a hacker to impersonate another user. So when
creating a session manager, for example, you could create
some other id to reference the SessionID internally, which
would allow you to control the sessions. This kind of application
would best be served under a secure web server.
<font face="courier new" size=3><pre>
</pre></font>The <a href=eg/global_asa_demo.asp>./site/eg/global_asa_demo.asp</a> script makes use of this routine
to display all the data in current user sessions.</font>
<p>
<a name=%24Application7441b337></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Application->SessionCount()</b></font>
<font face="courier new" size=3><pre>
</pre></font>This NON-PORTABLE method returns the current number of active sessions
in the application, and is enabled by the SessionCount configuration setting.
This method is not implemented as part of the original ASP
object model, but is implemented here because it is useful. In particular,
when accessing databases with license requirements, one can monitor usage
effectively through accessing this value.</font>
<p>
<a name=%24Server%20Objeed08cf85></a>
<font face=verdana><font class=title size=+0 color=#555555><b>$Server Object</b></font>
<font face="courier new" size=3><pre>
</pre></font>The server object is that object that handles everything the other
objects do not. The best part of the server object for Win32 users is
the CreateObject method which allows developers to create instances of
ActiveX components, like the ADO component.</font>
<p>
<a name=%24Server-%3E%7BSc74a89b4a></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Server->{ScriptTimeout} = $seconds</b></font>
<font face="courier new" size=3><pre>
</pre></font>Not implemented. May never be. Please see the
Apache Timeout configuration option, normally in httpd.conf.</font>
<p>
<a name=%24Server-%3ECon7d9785f8></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Server->Config($setting)</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension. Allows a developer to read the <a href=config.html><font size=-1 face=verdana><b>CONFIG</b></font></a>
settings, like Global, GlobalPackage, StateDir, etc.
Currently implemented as a wrapper around
<font face="courier new" size=3><pre>
Apache->dir_config($setting)
</pre></font>May also be invoked as $Server->Config(), which will
return a hash ref of all the PerlSetVar settings.</font>
<p>
( run in 1.309 second using v1.01-cache-2.11-cpan-39bf76dae61 )