我所在的团队也遇到过这样的问题
解决的办法是用cookie的,曾经想过用session
但是没有成功
因为所作的网站有几台服务器,其中有php的,有asp.net的,都是做web服务器的
整个管理系统是用php写的,但是网站有一部分针是对asp.net服务器上一个板块的管理
也就是说问题是如何让php通知asp.net程序知道已经登陆
实现方法:在php服务器上有一个checkright.php(根据u和p判断是否为管理员登陆,若是则echo "yes";否则echo "no";)
管理员登陆管理系统后,用setcookie把用户名和密码存储
在使用管理系统过程中,用asp.net那一块时,所用的程序都需要下面的内容,当然最好把下面的写成webservice了,我们就是这样做的
us = System.Web.HttpContext.Current.Request.Cookies["username"].Value.ToString();
pa = System.Web.HttpContext.Current.Request.Cookies["password"].Value.ToString();
然后
WebClient dfile=new WebClient();
string url_1 = "webserver/checkright.php?u="+us+"&p="+pa;
string result = "";
int flag;
Stream myStream = dfile.OpenRead(url_1);
StreamReader sr = new StreamReader(myStream);
try
{
result=sr.ReadLine();
if(result=="yes")
{
flag=1;
}
else
{
         flag=0;
}
}
catch
{
return -1;
}
finally
{
dfile.Dispose();
myStream.Close();
sr.Close();
}
return flag;
每一个asp.net页面都可以根据flag来确定用户是否已经登陆了