Get session id for the current client
SessionID.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
Session["ProductName"] = "HP-2133 Laptop";
Label1.Text = "Session read<br />";
Label1.Text += "SessionID: " + Session.SessionID;
Label1.Text += "<br />Product Name: " + Session["ProductName"];
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>asp.net session example: how to get SessionID (session id) for the current client</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Red">asp.net session example: Get SessionID</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
ForeColor="Teal"
>
</asp:Label>
</div>
</form>
</body>
</html>
