index.aspx
if (!this.IsPostBack)
{
hdid = Convert.ToInt32(Request.QueryString["hdid"]);
if (Request.Cookies["9gg"] != null)
{
openid = Request.Cookies["9gg"]["openid"].ToString();
}
else
{
//openid = "aaaaaaaaaaaaa";
}}
{
hdid = Convert.ToInt32(Request.QueryString["hdid"]);
if (Request.Cookies["9gg"] != null)
{
openid = Request.Cookies["9gg"]["openid"].ToString();
}
else
{
//openid = "aaaaaaaaaaaaa";
}}
getopenid.aspx.cs
public partial class getopenid : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string hdid = Request.QueryString["hdid"].ToString();
string tplcurl = Tplcurl(Convert.ToInt32(hdid));
if (Request.QueryString["openid"] != null)
{
string openid = Request.QueryString["openid"].ToString();
if (Request.Cookies["9gg"] == null)
{
//写入cookie
HttpCookie cookie = new HttpCookie("9gg");
DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(1, 0, 0, 0, 0);//设置过期时间1天过期
cookie.Expires = dt.Add(ts);//设置过期时间
cookie.Values.Add("openid", openid);
System.Web.HttpContext.Current.Response.AppendCookie(cookie);
}
else
{
HttpCookie cookie = Request.Cookies["9gg"];
//如果cookie存在修改cookie
cookie.Values.Set("openid", openid);
Response.AppendCookie(cookie);
}
Response.Redirect("index.aspx?hdid=" + hdid);
}
else
{
Response.Redirect(tplcurl);
}
}
}}
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string hdid = Request.QueryString["hdid"].ToString();
string tplcurl = Tplcurl(Convert.ToInt32(hdid));
if (Request.QueryString["openid"] != null)
{
string openid = Request.QueryString["openid"].ToString();
if (Request.Cookies["9gg"] == null)
{
//写入cookie
HttpCookie cookie = new HttpCookie("9gg");
DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(1, 0, 0, 0, 0);//设置过期时间1天过期
cookie.Expires = dt.Add(ts);//设置过期时间
cookie.Values.Add("openid", openid);
System.Web.HttpContext.Current.Response.AppendCookie(cookie);
}
else
{
HttpCookie cookie = Request.Cookies["9gg"];
//如果cookie存在修改cookie
cookie.Values.Set("openid", openid);
Response.AppendCookie(cookie);
}
Response.Redirect("index.aspx?hdid=" + hdid);
}
else
{
Response.Redirect(tplcurl);
}
}
}}
浙公网安备 33010602011771号