File: global_asa_demo.asp

package info (click to toggle)
libapache-asp-perl 2.63-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,120 kB
  • sloc: perl: 6,044; php: 409; sh: 62; lisp: 22; makefile: 10
file content (94 lines) | stat: -rwxr-xr-x 2,350 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/perl /usr/bin/asp-perl

<!--#include file="header.inc" args=""-->

This example serves as how one may use the global.asa 
file event handlers.  Please see the global.asa file
for the code relevant to this example.

<p>

The following table lists the sessions that have been
recorded in the global.asa file into $Application.  When
a session ends, its time lived is recorded and displayed
below.  Active sessions are also listed.  
<p>
<%
my $count;
my @sessions;
for(keys %{$Application}) {
	next unless ($_ =~ /^Session/);
	$count++;
	push(@sessions, $_);
}
%>
<center>
<%=$count%> Sessions Recorded <br>

<!-- 
	Please read the README or the perldoc Apache::ASP before using
	the following routine in your code, as it is non-portable.
-->
<%=$Application->SessionCount()%> Active Sessions
<p>
<% if($count > 200) { %>
<center>  First 200 of <%= $count %> displayed. </center>
<% } %>
<p>
<table border=0 width=90%>
	<tr><td colspan=2><hr size=1></td></tr>
<%
$count = 0;
for(sort @sessions) {
	next unless ($_ =~ /^Session/);
	last if $count++ >= 200;

	my $session_id = $_;
	$session_id =~ s/^Session//io;
	my $session = $Application->GetSession($session_id);
	my $session_data = $session ? { %$session } : undef;

	my $session_time = ($Application->{$_} eq '?') ?
		"in session" : "$Application->{$_} seconds";

	%>
	<tr bgcolor="#c0c0c0">
		<td><%=substr($session_id, 0, 6)."..."%></td>
		<td><%=$session_time%></td>
	</tr>	
	<tr><td colspan=2><pre><%=$session_data ? Data::Dumper->Dump([$session_data]) : '' %></pre></td></tr>

	<tr><td colspan=2><hr size=1></td></tr>
	<%
}
%>
</table>
</center>
<p>
To see multiple sessions listed you may  
create a 2nd session by closing and then reopening
the browser you are using to view this file, or 
you may also open a 2nd kind of browser to create this 2nd
session.  There is only one session-id generated
per browser session for an asp application.

<hr size=1>

Here is a simple use of the Script_OnStart & Script_OnEnd
event handlers, keeping track of the number of scripts
executed this session:

<center>
<table>
<tr>
	<td align=right>Scripts Started This Session:</td>
	<td><tt><%=$Session->{Started}%></tt></td>
</tr>
<tr>
	<td align=right>Scripts Ended This Session:</td>
	<td><tt><%=$Session->{Ended} || 0 %></tt></td>
</tr>
</table>
</center>

<!--#include file="footer.inc"-->