How To Display Something When A Cookie Expires
Jul 13, 2010
I'm wanting to show a video when a person comes to the site and doesn't have a cookie. After they see the video, a cookie is added, but when the cookie expires, the video is played again.
if (Request.Cookies["x"] != null)
{
//do nothing
}
else
{
ModalPopupExtender1.Show();
Response.Cookies["x"].Value = DateTime.Now.ToString();
Response.Cookies["x"].Expires = DateTime.Now.AddHours(24);
}
I would think this would work correctly, however the movie only shows if the browser is cleared of all cookies. 24hrs later the movie will not play.
View 2 Replies
Similar Messages:
Jul 6, 2010
My users need to stay logged in for 1 day, so I used a persistent authentication cookie with an expiration of 1 day but it still times out after 20 minutes (which is the default timeout for the session, not the cookie).
This is my code:
<authentication mode="Forms">
<forms loginUrl="Login.aspx" protection="All" path="/" />
</authentication>
FormsAuthenticationTicket ticket =
new FormsAuthenticationTicket(1, "username", DateTime.Now, DateTime.Now.AddDays(1), true, "userdata");
string encTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
cookie.Expires = ticket.Expiration;
HttpContext.Current.Response.Cookies.Add(cookie);
I also have manually-generated validation and decryption keys:
<machineKey>
validationKey="......."
decryptionKey="......."
validation="SHA1"
</machineKey>
View 19 Replies
Aug 16, 2010
I want to display a pop up when the session expires. I'm using the MVC 1 and jquery. I've some .aspx and some .ascx pages.
How do i achieve that? Right now, the application redirects to Login page. But before login page shows up, i want to display the message.
View 1 Replies
Oct 21, 2010
I simply want to display a message on the login page when the user is automatically redirected there after requesting a page that they were logged in for but their session has now expired. So essentially if the user was working but stepped away for a lunch break without logging out I want the system to tell them why they were sent back to the login page.
Something like "You have been idle for too long so you must log back in".
This has to be easy I am just running into a wall here. I thought about getting the original ticket and reading the expiration date but I'm a little lost.
View 4 Replies
Apr 2, 2010
i have cookie that has a value in it but i dont no how to display that in the
text box n i'm using asp.net mvc n c# as my language
how to display a cookie value in a text box
View 7 Replies
Sep 8, 2010
I am busy building a shopping cart with cookies. I have datalist which I populate from the cookies with a delete button next to each cookie
[Code]....
Now the problem is that when I hit the delete / remove button to expire the cookie, what happens when repopulating the datalist is that it shows the original cookie with all it's values as well as a new entry where all the values are blank.
View 3 Replies
May 10, 2010
I want to change the value in a cookie:
HttpCookie hc = new HttpCookie("HiddenColumns");
hc.Value = customView.HiddenFields;
hc.Expires = DateTime.Now.AddDays(365);
Response.SetCookie(hc);
Or this way:
Response.Cookies["HiddenColumns"].Value = customView.HiddenFields;;
Response.Cookies["HiddenColumns"].Expires = DateTime.Now.AddDays(365);
But when I retrieve the cookie value, it is still old, unless I do postback. I don't want to use Redirect.
View 2 Replies
Jun 8, 2010
I'm trying to use a webservice that first expects the clients to login, to retrieve a cookie to re-use.
This is done through a login(string user, string pass) method on the webservice.
Doing this through a browser works fine, we get a cookie, and we can see the cookie via Fiddler or whatvever proxysniff thingy.
Time to do the same in ASP.Net, so we use the WSDL and generate a nice proxy class, and it works fine to call the login() method, but Never Ever does a cookie get set !
I already used the "cookiejar" technique - which means i create an instance of a CookieContainer and assign it to the proxyclass like this;
var cookies = new CookieContainer(3);
View 3 Replies
Jun 14, 2010
I am a bit baffled here; using IE7, ASP.NET 2.0 and Cassini (the VS built-in web server; although the same thing seems to be true for "real" applications deployed in IIS) I am looking for the session-id-cookie. My test page shows a session id (by printing out Session.SessionId) and Response.Cookies.Keys contains ASP.NET_SessionId. So far so good.
But I cannot find the cookie in IEs cookie-store! Nor does "remove all cookies" reset the session (as it does in FF)... So where - I am tempted to write that four letter word - does IE store that bloody cookie? Or am I missing something? By the way there is no hidden field with a session id either, as far as I can see. If I check in FF there is a cookie called ASP.NET_SessionId as I would expect. And as mentioned above deleting that cookie does start a new session; as I would expect.
View 1 Replies
Feb 3, 2011
This is my function that is called when a login is successful. (I am very new to this FormAuthentication thing)
public static void CreateLoginCookie(User u)
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(u.Id.ToString(), true, 9*60);
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) { Expires = DateTime.Now.AddHours(9) };[code]....
I want the user stay logged in for 9 hours, but it doesn't work. They get logged out after an hour or two.
Could someone tell me what I am missing?
View 1 Replies
Jan 13, 2010
I want to know page name when session expires so that I redirect user to that page after relogin. I am checking session in Master page's page load event
View 4 Replies
Nov 16, 2010
I am using Session variable throughout in my application and my timeout is 1 hour. Here I need to catch the exception for session expires in any global way across my application.
View 3 Replies
Feb 8, 2010
How to write to a file the content of cache when Cache expires.
View 1 Replies
Aug 18, 2010
How does session expires when the browser is closed?
View 4 Replies
Aug 29, 2010
i want your opinion about the
Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 20))that i have seen in some sites that is used for refresh the page every time a little bit before the session expires
View 5 Replies
Aug 2, 2010
i host my web site into a shared hosting and i need to set expiration header using iis but i didn't find my hosting allow this feature so , is there any way to set it into my web configuration or into my code ??
View 2 Replies
May 2, 2010
I am using a timer in the master page of my web site in order to keep a 'status bar' up to date with all sorts of information.The issue is that the whole point of session expiry goes to waste, because a postback is always being made (although asynchronic) to the server.
How can i still expire the session after a wanted period of time?
View 6 Replies
Jan 28, 2011
I am using dynamic query to get data from database (SQL) Whenever the query execution time is more than 1 min, i get a Timeout expiry error in my web page.
View 6 Replies
Aug 3, 2010
I cache information about the currently logged in user in the session. This info lazy loads whenever a CurrentUser property on my global application class is used. It does this by calling GetUser() on my custom implementation of MembershipProvider, which either loads the user up from the session, or loads the user from the DB and throws the user object in the session.
How should I handle this scenario?
User logs in. Administrator deletes user (or deactivates...the point is they can't log in any more). User's session expires. User navigates to a page or makes a request, or whatever.
Currently if this scenario occurs, NullReferenceExceptions are thrown all over the place, because the ASP .NET framework calls GetUser() which returns nothing because it can't find the user in the database (and there's nothing in the session because it expired).
View 2 Replies
Mar 18, 2011
I have a simple ASP.NET 4 site. I am using Forms Authentication. I have Session timeout set to 20 minutes. Also when the user authenticates I set the AuthenticationTicket to expire in 20 minutes. So normally everything works fine. If there is more than 20 minutes of inactivity and the user requests a page on the site they are redirected back to the Login page as I would expect.
However, let's say that the user is on a page that contains a form. Then they wait 25 minutes. Then they go to submit the form. Instead of being redirected back to the Login page, the site attempts the postback and I immediately get errors because there is code in the postback that attempts to get information out of Session.
It seems like ASP.NET does not redirect back to Login on postback if the AuthenticationTicket and Session has expired. How can I handle this? I hope I don't have to write special code on each page.
ADDED: web.config code
<location path="ForgotLogin.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Login.aspx"></forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
View 3 Replies
Jan 7, 2011
i have a website and i know that the session expires and it gives me instance of object not set error.
I have a masterpage could i do it in there on page_load?
View 3 Replies
Jan 7, 2011
I need to add an expires header to my .less files in IIS7. Not quite sure how to do it.
View 2 Replies
Aug 14, 2010
In myapplication i have done a thing like if some one purchase a tool for and if the license provided is for some few days (suppose for a week or an year).. How to send a mail automatically to the ID given by him before a day or a few days .
View 3 Replies
Sep 14, 2010
I am trying to delete Files and Directory through ASP.NET3.5 (C#)web application.
But as soon as DirectoryFile is deleted It automatically redirects me to Login Page.
It means I am lossing my session on deleting File/Directory.
View 5 Replies
Aug 9, 2010
I have an asp.net web page which works with a database. When I first upload it I never disposed the connections so after using the different modules of the application for sometime it would suddenly stop working saying the connection pool filled or something like that.To fix it when a user clicked a button I opened the connection, tell the database what I needed and finally disposed the connection.
This seemed to fix everything, in fact you can work with application all you want, the problem comes if you stop using it for certain time.So for instance, I have a module in my webpage where user can capture information for a certain product. When the user clicks in one button the info gets into the database. If the user is continuosly capturing data everything works fine, but if it goes for about 10 min when he clicks the button he will receive an error. To fix this the user has to log-in again.
Every module opens a connection to the database to verify the user identity, but then after it verifies it I dispose the connection so I don't think there is a problem.
View 3 Replies