Set Cookie at log Inhttp://forums.asp.net/t/1790079.aspx/1?Set+Cookie+at+log+InSun, 08 Apr 2012 06:27:06 -040017900794920123http://forums.asp.net/p/1790079/4920123.aspx/1?Set+Cookie+at+log+InSet Cookie at log In <p>Hi All,</p> <p>I have a page with a form on it, and after a user fills out the information in the page they can then enter the site after hitting a submit button. The users are complaining that they have to do this every time they go to the site. Is there a tutorial or somewhere I could be pointed to learn how to set a cookie so a returning visitor to the site doesnt have to fill out the form again?</p> <p>Thanks</p> <p>A</p> <p></p> 2012-04-06T19:37:47-04:004920169http://forums.asp.net/p/1790079/4920169.aspx/1?Re+Set+Cookie+at+log+InRe: Set Cookie at log In <p>i think this will do it for you.&nbsp; You have to change the timeout.</p> <pre class="prettyprint">Dim ticket As New FormsAuthenticationTicket(1, UserId, DateTime.Now, DateTime.Now.AddMinutes(30), False, String.Empty, FormsAuthentication.FormsCookiePath) Dim encryptedTicket As String = FormsAuthentication.Encrypt(ticket) Dim authCookie As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) Response.Cookies.Add(authCookie)</pre> <p></p> 2012-04-06T20:28:39-04:004920175http://forums.asp.net/p/1790079/4920175.aspx/1?Re+Set+Cookie+at+log+InRe: Set Cookie at log In <p>Hi UstesG,</p> <p>I dont know JavaScript but should I replace the &quot;FormsCookieName&quot; with the submit button name from the form on the site? I kind of get the gist of what the rest of it means, but Dim isnt that vbscript or does JavaScript use that too?</p> <p>Thanks again,</p> <p>A</p> <p></p> 2012-04-06T20:40:06-04:004920181http://forums.asp.net/p/1790079/4920181.aspx/1?Re+Set+Cookie+at+log+InRe: Set Cookie at log In <p>didn't know you meant from JS.&nbsp; This goes in the code behind page in the locin button click event.&nbsp; Once authorized you set the formsAuthentication ticket to not expire for 10 days or whatever you want.</p> 2012-04-06T20:42:22-04:004920194http://forums.asp.net/p/1790079/4920194.aspx/1?Re+Set+Cookie+at+log+InRe: Set Cookie at log In <p>oh, sorry the site is an html site, so that is why I was researching JavaScript. If it were an asp.net site, I would have made a t-sql check. :-)</p> 2012-04-06T20:56:46-04:004920779http://forums.asp.net/p/1790079/4920779.aspx/1?Re+Set+Cookie+at+log+InRe: Set Cookie at log In <p>Hello,</p> <p>Check the below links on how to set/get cookies using javascripts. I Googled them for you.</p> <p><a href="http://www.w3schools.com/js/js_cookies.asp">http://www.w3schools.com/js/js_cookies.asp</a></p> <p><a href="http://techpatterns.com/downloads/javascript_cookies.php">http://techpatterns.com/downloads/javascript_cookies.php</a></p> <p><a href="http://www.htmlgoodies.com/beyond/javascript/article.php/3470821/So-You-Want-To-Set-A-Cookie-Huh.htm">http://www.htmlgoodies.com/beyond/javascript/article.php/3470821/So-You-Want-To-Set-A-Cookie-Huh.htm</a></p> <p><a href="http://www.perlscriptsjavascripts.com/js/cookies.html">http://www.perlscriptsjavascripts.com/js/cookies.html</a></p> <p><a href="http://www.thonky.com/javascript-and-css-guide/set-cookie/">http://www.thonky.com/javascript-and-css-guide/set-cookie/</a></p> <p><a href="http://www.howtocreate.co.uk/tutorials/javascript/cookies">http://www.howtocreate.co.uk/tutorials/javascript/cookies</a></p> 2012-04-07T11:40:20-04:004921417http://forums.asp.net/p/1790079/4921417.aspx/1?Re+Set+Cookie+at+log+InRe: Set Cookie at log In <p>Hi,</p> <p>You can check few posts here</p> <p><a href="http://delicious.com/anupdg/cookie">http://delicious.com/anupdg/cookie</a></p> 2012-04-08T06:27:06-04:00