Session Variables <% If Session("City") = "Portland" Then Session("City") = "Portland, OR" End If Response.Write "Hello: " & Session("UserName") & ".
" Response.Write "For your records your account number is: " _ & Session("UserID") & ".
" Response.Write "How are things in " & Session("City") & "?
" %> CodePage <% Session.CodePage = 1252 Response.Write "CodePage used: " & Session.CodePage & "
" Response.Write "1é æ ç ê ë ì í î ï ð Ê Î Ð" & "
" Session.CodePage = 932 Response.Write "CodePage used: " & Session.CodePage & "
" Response.Write "1é æ ç ê ë ì í î ï ð Ê Î Ð" & "
" %> LCID <% Session.LCID = 1033 Response.Write "US format: " & Now & " " _ & formatcurrency(1234.56) & "
" Session.LCID = 2057 Response.Write "UK format: " & Now & " " _ & formatcurrency(1234.56) & "
" Session.LCID = 1049 Response.Write "Russia format: " & Now & " " _ & formatcurrency(1234.56) & "
" Session.LCID = 1032 Response.Write "Greek format: " & Now & " " _ & formatcurrency(1234.56) & "
" Session.LCID = 2049 Response.Write "Iraq format: " & Now & " " _ & formatcurrency(1234.56) & "
" Session.LCID = 3073 Response.Write "Egypt format: " & Now & " " _ & formatcurrency(1234.56) & "
" Session.LCID = 6154 Response.Write "Panama format: " & Now & " " _ & formatcurrency(1234.56) & "
" %> Application Variables <% Option Explicit Dim OrderTotal Dim SandH Dim TotalDue OrderTotal = Session("OrderTotal") * Application("CurrentDiscount") SandH = OrderTotal * Application("ShipHandPercent") If SandH < Application("MinShipHand") Then SandH = Application("MinShipHand") End If TotalDue = SandH + OrderTotal %> Application Variables Collection <% Option Explicit Dim MyApp For Each MyApp in Application.Contents Response.Write "Application Variable Name: " & MyApp _ & " Value: " & Application(MyApp) & "
" Next %> Lock <% Option Explicit Dim conn Dim RSPageHits set conn = server.createobject ("adodb.connection") conn.open "ASPBook", "sa", "yourpassword" set RSPageHits = conn.Execute("select Hits from RSPageHits") Application("PageHits") = RSPageHits("Hits") %> Unlock <% Application.Lock Application("PageHits") = Application("PageHits") + 1 Application.Unlock %> App OnStart Sub Application_OnStart Application("CurrentDiscount") = .9 Application("MinShipHand") = 12 Application("MinQuantity") = 2 Application("ShipHandPercent") = .07 End Sub Sub Application_OnStart Application("DNS") = "OC" Application("UserName") = "Admin" Application("Password") = "yourpassword" Application("AllowNew") = "Yes" Application("AllowEnroll") = "Yes" Application("Path2Logo") = "./images/logo.gif" Application("AllowDrop") = "No" Application("ChatMode") = "External" End Sub <% Option Explicit Dim conn Dim RSCourses if Application("AllowEnroll") = "Yes" then set conn = server.createobject ("adodb.connection") conn.open Application("DNS"), Application("UserName"), _ Application("Password") set RSCourses = conn.execute ("SELECT CourseID, CourseName, " _ & CourseDescription FROM OCCourses") %>
Select a course to enroll <% do until RSCourses.EOF %> ">
<% Response.Write RSCourses("CourseName") %> - <% Response.Write RSCourses("CourseDescription") %> <% RSCourses.MoveNext loop end if %> Session OnEnd Sub Session_OnEnd Dim objDNS Dim conn Dim hostname Dim GMT set objDNS = server.createobject("INet.DNS.1") objDNS.ip = request.servervariables("remote_addr") If objDNS.Host <> "" Then hostname = objDNS.Host Else hostname = request.servervariables("remote_addr") End If GMT = Cstr (dateadd("h", 6, now())) set conn = server.createobject ("adodb.connection") conn.open "IISLog", "sa", "yourpassword" SQL = "update iislog..sessions set session_end = '" & GMT _ & "', hostname = '" & hostname & "'" SQL = SQL & " where Session_id = " & cstr(Session("session_id")) conn.Execute SQL End Sub