<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Security</title><link>http://forums.asp.net/25.aspx</link><description>All about ASP.NET security (authentication, authorization, membership, roles, etc.) and the Login controls. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=24&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Login Control. Remember Me Not working</title><link>http://forums.asp.net/thread/2673975.aspx</link><pubDate>Thu, 09 Oct 2008 22:59:28 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2673975</guid><dc:creator>n_m</dc:creator><author>n_m</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2673975.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2673975</wfw:commentRss><description>&lt;p&gt;Thanks everyone. I just wanted to followup. After some more research, i&amp;nbsp;found the solution.&amp;nbsp;I noticed that the cookie&amp;#39;s were being created, but for some reason the login page would just not redirect. Then i found the following example on some forum, i added to the page_load and now the rememberme checkbox works. &lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;If&lt;/span&gt; User.Identity.IsAuthenticated = &lt;span class="kwd"&gt;True Then&lt;/span&gt;
            Response.Redirect(Login1.DestinationPageUrl)
        &lt;span class="kwd"&gt;End If&lt;/span&gt;&lt;/pre&gt;&amp;nbsp; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Login Control. Remember Me Not working</title><link>http://forums.asp.net/thread/2650941.aspx</link><pubDate>Sun, 28 Sep 2008 23:33:53 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2650941</guid><dc:creator>yasserzaid</dc:creator><author>yasserzaid</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2650941.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2650941</wfw:commentRss><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;try the below code&lt;/p&gt;
&lt;div class="post-body entry-content"&gt;Use this code:&lt;br /&gt;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;if (!Page.IsPostBack)&lt;br /&gt;{&lt;br /&gt;CheckBox cek = (CheckBox)Login1.FindControl(&amp;quot;RememberMe&amp;quot;);&lt;br /&gt;if (Request.Cookies[&amp;quot;username&amp;quot;] == null Request.Cookies[&amp;quot;username&amp;quot;].Value.ToString().Trim() == &amp;quot;&amp;quot;)&lt;br /&gt;{&lt;br /&gt;cek.Checked = false;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Login1.UserName = Request.Cookies[&amp;quot;username&amp;quot;].Value.ToString();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;
&lt;p&gt;&lt;br /&gt;protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)&lt;br /&gt;{&lt;br /&gt;CheckBox cek = (CheckBox)Login1.FindControl(&amp;quot;RememberMe&amp;quot;);&lt;br /&gt;if (cek.Checked == true)&lt;br /&gt;{&lt;br /&gt;HttpCookie cookie = new HttpCookie(&amp;quot;username&amp;quot;);&lt;br /&gt;cookie.Value = Login1.UserName;&lt;br /&gt;&lt;br /&gt;cookie.Expires = DateTime.Now.AddDays(1);//cookie Expires&lt;br /&gt;HttpContext.Current.Response.AppendCookie(cookie);&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;HttpContext.Current.Response.Cookies.Remove(&amp;quot;username&amp;quot;);&lt;br /&gt;}&lt;br /&gt;cek.Checked = false;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;//--- another way&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;protected void Page_Load(object sender, EventArgs e)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;if (Request.Cookies[&amp;quot;MyCookie&amp;quot;] != null)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;TextBox pass = (TextBox)Login1.FindControl(&amp;quot;Password&amp;quot;); pass.Attributes.Add(&amp;quot;value&amp;quot;, Request.Cookies[&amp;quot;MyCookie&amp;quot;][&amp;quot;password&amp;quot;]); Login1.UserName = Request.Cookies[&amp;quot;MyCookie&amp;quot;][&amp;quot;username&amp;quot;];&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;protected void Login1_LoggedIn(object sender, EventArgs e)&lt;/p&gt;
&lt;p&gt;{ &lt;/p&gt;
&lt;p&gt;HttpCookie cookie1 = new HttpCookie(&amp;quot;MyCookie&amp;quot;); &lt;/p&gt;
&lt;p&gt;cookie1.Values.Add(&amp;quot;username&amp;quot;, Login1.UserName);&lt;/p&gt;
&lt;p&gt;cookie1.Values.Add(&amp;quot;password&amp;quot;, Login1.Password); &lt;/p&gt;
&lt;p&gt;cookie1.Expires = DateTime.Now.AddDays(1);//cookie Expires HttpContext.Current.Response.AppendCookie(cookie1);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;div style="CLEAR:both;"&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style="CLEAR:both;"&gt;Good Luck&lt;/div&gt;&lt;/div&gt;</description></item><item><title>Re: Login Control. Remember Me Not working</title><link>http://forums.asp.net/thread/2649470.aspx</link><pubDate>Sat, 27 Sep 2008 02:50:59 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2649470</guid><dc:creator>anas</dc:creator><author>anas</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2649470.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2649470</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;n_m:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Another question. If the user closes the browser is the login cookie still be preserved? I would like to have it so users can still close the browser and still be able to be auto logged in within a certain amount of time.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;To allow asp.net remember your users , you need to make sure that the authentication cookie will be persisted , this can be done by setting the following Login control properties : &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Login ID=&amp;quot;Login1&amp;quot; runat=&amp;quot;server&amp;quot; RememberMeSet=&amp;quot;true&amp;quot; DisplayRememberMe=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:Login&amp;gt; &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Login Control. Remember Me Not working</title><link>http://forums.asp.net/thread/2649388.aspx</link><pubDate>Fri, 26 Sep 2008 23:58:01 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2649388</guid><dc:creator>hans_v</dc:creator><author>hans_v</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2649388.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2649388</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;n_m:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; 
&lt;p&gt;I was under the impression that this would work automatically.&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;Well, it does. You&amp;#39;ll need to set the correct properties in web.config.&lt;/p&gt;
&lt;p&gt;Generate a machine key using &lt;a class="" href="http://www.orcsweb.com/articles/aspnetmachinekey.aspx" target="_blank"&gt;&lt;font color="#5403fa"&gt;this online tool&lt;/font&gt;&lt;/a&gt;&amp;nbsp;and place it in your web.config (if you don&amp;#39;t, users are logged out when the application recycles). And then set the properties as below:&lt;/p&gt;
&lt;p&gt;&amp;lt;&lt;font color="#800000" size="2"&gt;forms&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;loginUrl&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;Login.aspx&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;protection&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;All&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;timeout&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;60000&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;name&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;.ASPXAUTH&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;slidingExpiration&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;true&lt;/font&gt;&lt;font size="2"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;/&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Proctection should be All, timeout is the number of minutes the cookie expires, name is the name of the cookie. Be carefull, since there&amp;#39;s &lt;a class="" href="http://www.worldofasp.net/ASP-NET/re-1882_A-Potential-Security-Hole-with-Remember-Me-Next-Time.aspx" target="_blank"&gt;a Potential Security Hole&lt;/a&gt; when using a persistent security cookie!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Login Control. Remember Me Not working</title><link>http://forums.asp.net/thread/2649051.aspx</link><pubDate>Fri, 26 Sep 2008 18:57:18 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2649051</guid><dc:creator>n_m</dc:creator><author>n_m</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2649051.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2649051</wfw:commentRss><description>&lt;p&gt;Thanks.Ill try this. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;Another question. If the user closes the browser is the login cookie still be preserved? I would like to have it so users can still close the browser and still be able to be auto logged in within a certain amount of time.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Login Control. Remember Me Not working</title><link>http://forums.asp.net/thread/2647519.aspx</link><pubDate>Fri, 26 Sep 2008 07:38:26 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2647519</guid><dc:creator>yrajasekhar</dc:creator><author>yrajasekhar</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2647519.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2647519</wfw:commentRss><description>&lt;p&gt;Hi you have to store a persistent cookie on user machine if remember me is checked see the following code (if part is when remember me is checked)&amp;nbsp;&lt;pre class="coloredcode"&gt; &lt;span class="kwd"&gt;if&lt;/span&gt; (cbRememberMe.Checked)
                {
                    &lt;span class="kwd"&gt;int&lt;/span&gt; cookietimeout = 360;
                    FormsAuthenticationTicket authTicket = &lt;span class="kwd"&gt;new&lt;/span&gt;
                        FormsAuthenticationTicket(txtUserName.Text, &lt;span class="kwd"&gt;true&lt;/span&gt;, cookietimeout);
                    &lt;span class="kwd"&gt;string&lt;/span&gt; encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                    HttpCookie cookie = &lt;span class="kwd"&gt;new&lt;/span&gt; HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                    cookie.Expires = authTicket.Expiration;
                    HttpContext.Current.Response.Cookies.Set(cookie);
                }
                &lt;span class="kwd"&gt;else&lt;/span&gt;
                {
                    FormsAuthentication.SetAuthCookie(txtUserName.Text, &lt;span class="kwd"&gt;false&lt;/span&gt;);
                }&lt;/pre&gt;&amp;nbsp; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Login Control. Remember Me Not working</title><link>http://forums.asp.net/thread/2646767.aspx</link><pubDate>Thu, 25 Sep 2008 22:26:48 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2646767</guid><dc:creator>n_m</dc:creator><author>n_m</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2646767.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=2646767</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I created a login page using the login control. I am also using a cusomter membershipprovider, with a new validateuser function that i wrote. However the rememberme checkbox does not seem to work. Do i need to write code to handle if the rememberme checkbox was checked and redirect to the destinationpageurl? I was under the impression that this would work automatically.&amp;nbsp;Any help would be appreciated. Thanks!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;N&lt;/p&gt;</description></item></channel></rss>