cvsuser 02/02/05 14:29:13
Modified: P5EEx/Blue/P5EEx/Blue Session.pm
Log:
added default html() and get_session_id() methods
Revision Changes Path
1.5 +47 -2 p5ee/P5EEx/Blue/P5EEx/Blue/Session.pm
Index: Session.pm
===================================================================
RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/Session.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -r1.4 -r1.5
--- Session.pm 1 Feb 2002 20:35:22 -0000 1.4
+++ Session.pm 5 Feb 2002 22:29:12 -0000 1.5
@@ -1,6 +1,6 @@
#############################################################################
-## $Id: Session.pm,v 1.4 2002/02/01 20:35:22 spadkins Exp $
+## $Id: Session.pm,v 1.5 2002/02/05 22:29:12 spadkins Exp $
#############################################################################
package P5EEx::Blue::Session;
@@ -135,9 +135,54 @@
=cut
+my $seq = 0;
+
sub get_session_id {
my $self = shift;
- "default"; # subclasses will override this
+ return $self->{session_id} if (defined $self->{session_id});
+ my ($session_id);
+ $seq++;
+ $session_id = time() . ":" . $$;
+ $session_id .= ":$seq" if ($seq > 1);
+ $self->{session_id} = $session_id;
+ $session_id;
+}
+
+#############################################################################
+# html()
+#############################################################################
+
+=head2 html()
+
+The html() method ...
+
+ * Signature: $html = $session->html();
+ * Param: void
+ * Return: $html string
+ * Throws: <none>
+ * Since: 0.01
+
+ Sample Usage:
+
+ $session->html();
+
+The html() method on a session may be used by Contexts which embed session
+information in a web page being returned to the user's browser.
+(Some contexts do not use HTML for the User Interface and will not call
+this routine.)
+
+The most common method of embedding the session information in the HTML
+is to encode the session_id in an HTML hidden variable (<input type=hidden>).
+That is what this implementation does.
+
+=cut
+
+sub html {
+ my ($self, $options) = @_;
+ my ($session_id, $html);
+ $session_id = $self->get_session_id();
+ $html = "<input type=\"hidden\" name=\"p5ee.session_id\"
value=\"$session_id\">";
+ $html;
}
1;