Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting an ASP Session

Tags:

asp-classic

I am working on a system using ASP that requires session control. What is the syntax for starting and retrieving a session value using ASP?

like image 293
James Obuhuma Avatar asked Mar 11 '26 13:03

James Obuhuma


2 Answers

Before someone shouts at your for not using Google first check out the below link

http://www.w3schools.com/asp/asp_sessions.asp

like image 148
DotNetDublin Avatar answered Mar 14 '26 16:03

DotNetDublin


Syntax:

<% Session[.collection|property|method|event] %>

Example

<% Option Explicit %>
<html>
<head>
<title>First Page</title>
</head>
<body>
<%
    Session.TimeOut  = 60
    Session("SiteName") = "www.example.com"
    Session("Name") = "Mr.Incredible"
    Response.write("Session Created<br><br>")
    Response.write("<a href=redirect.asp>Check Session</a>")
%>
</body>
</html>

Redirect Page:

<% Option Explicit %>
<html>
<head>
<title>Redirect Page</title>
</head>
<body>
<%
    Response.write "Site Name = " & Session("SiteName") & "<br>"
    Response.write "Name = " & Session("Name")& "<br><br>"
%>
</body>
</html>
like image 43
Kasidesh Yontaradidthaworn Avatar answered Mar 14 '26 16:03

Kasidesh Yontaradidthaworn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!