cookes(username) = dt.Rows[0]["username"].ToString();                    cookes(Limit) = dt.Rows[0]["Limit"].ToString();
                    cookes(realname)=dt.Rows[0]["realname"].ToString();
Session["username"]=dt.Rows[0]["username"].ToString();

解决方案 »

  1.   

    cookes?没写过 cookie倒是写过 还有你发的源码啥意思啊
      

  2.   

    cookie(username) = dt.Rows[0]["username"].ToString();                    cookie(Limit) = dt.Rows[0]["Limit"].ToString();
                        cookie(realname) = dt.Rows[0]["realname"].ToString();
      

  3.   

    写错了,还有就是session(username)这个超过一定时间没失效,能否在网页关闭时才没起作用...
      

  4.   

    估计LZ写错了,是 cookie吧,cookie不是脚本控制的么,还有session在配置文件中应该有设置过过期的时间的,最后真心不明白LZ给的源码是干嘛的。
      

  5.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApp._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="txtCookie" runat="server" />
            <asp:Button ID="Button1" runat="server" Text="设置Cookie的值" 
                onclick="Button1_Click" />
        </div>
        </form>
    </body>
    </html>using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;namespace WebApp
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    if (Request.Cookies.Get("guwei") != null)
                    {
                        Response.Write(Request.Cookies["guwei"].Value);
                    }
                    else
                    {
                        Response.Write("没有cookie。");
                    }
                }
            }        protected void Button1_Click(object sender, EventArgs e)
            {
                Response.Cookies.Set(new HttpCookie("guwei", this.txtCookie.Text.Trim()));
            }
        }
    }