-
Notifications
You must be signed in to change notification settings - Fork 1
/
Site.master.cs
55 lines (50 loc) · 1.37 KB
/
Site.master.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Site : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack || !IsPostBack)
{
HttpCookie cookie = Request.Cookies["mycookie"];
if (Session["user"] != null || cookie != null)
{
login.Text = "My Profile";
logout.Text = "Logout";
}
else
{
login.Text = "Log In";
logout.Text = "Create My Account";
}
}
}
protected void logout_Click(object sender, EventArgs e)
{
if(logout.Text == "Create My Account")
{
Response.Redirect("~/Register.aspx");
}
else if(logout.Text == "Logout")
{
Response.Cookies["mycookie"].Expires = DateTime.Now.AddYears(-1);
Session.Clear();
Response.Redirect("~/Login.aspx");
}
}
protected void login_Click(object sender, EventArgs e)
{
if(login.Text == "Log In")
{
Response.Redirect("~/Login.aspx");
}
else if(login.Text == "My Profile")
{
Response.Redirect("~/MyProfile.aspx");
}
}
}