Set A Cookie To Expire After X Days?

Jul 3, 2011

I have this code (which I did not make) which basically makes a container with an X, so when I press the X, the div container closes. However, when you refresh the page, the div container will reappear again. How can I make it so when the person presses the X button, the person will never see the div container ever again (or for a set amount of time like 30 days) on that page?

I want to take it one step further, if possible, and make it so when the person presses the X button, he/she will never see the div container again throughout my site, as I plan on implementing the same div container throughout my site.

HTML Code:
<div id="bottom_ad">
<div id="close_ad" onclick="close_bottom_ad();">X</div>
<!-- Ad Content -->
[Code]......

View 7 Replies


ADVERTISEMENT

How To Set Cookie To Expire In Minutes

Mar 30, 2010

function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
Above is the code I'm using. I just copy/pasted it from another website, so I don't know how to change it. I want the expiration to be about 10 minutes. I tried decimals (0.007 day), but it doesn't work.

View 1 Replies View Related

Cookie To Not Expire For A Long Time?

May 31, 2010

I am using jQuery to set a cookie and the expiration date is:

date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));

which lasts for 1 day, but I would like the cookie to not expire for a long time, is this possible? I know google has one that like expires in 2035 or something but I would like this on to last long. What should I do?

View 4 Replies View Related

Cookie Doesn't Expire After Session

Mar 31, 2003

I have a page which I have protected using a password page. When the person viewing the site clicks on the link to the protected page, I have placed a script on onload that checks whether a cookie exists. If the cookie doesn't exist then the person is redirected to the password page. If they enter the correct password then the cookie is created using the following code and they are allowed to enter the protected page:

document.cookie="true";

If the cookie exists however, then they are allowed straight into the protected page. This is the code that I use to check whether or not the cookie exists: Code:

View 1 Replies View Related

Simple Cookie Expire Date

Sep 30, 2004

I'm trying to set my cookie to expire in 1 year but it dosen't seem to be working. here is my code. can anyone tell me what I am doing wrong?

function DeleteCookie (name,path,domain) {
if (GetCookie(name)) {
var temp = name + "=";
temp += ((path) ? "; path=" + path : "");
temp += ((domain) ? "; domain=" + domain : "");
temp += "; expires=Thu, 01-Oct-2005 00:00:01 GMT";
document.cookie = temp;
}

View 1 Replies View Related

Convert Days To Weeks And Days

Jan 17, 2010

converting days to weeks and remaining days. For example : Total days : 152 = 147 Weeks and 5 Days: so I want to write a function getWeeks(152) and it will return an array of 3 elements 0 will be weeks and 1 will be days.

View 4 Replies View Related

Creating Temporary Links That Expire?

Jul 23, 2005

I am developing a web site for a summer comedy series. The site has
links to buy tickets but I want them to disappear two hours before the
show begins. Does anyone know how to use a simple javascript that
shows and hides text and links after a date has passed?

View 3 Replies View Related

IE Events Expire (typeof = Unknown) After CallStack Finishes. (featuring: SetTimeout Scoping)

Feb 20, 2007

I wrote a pair of functions to enable scoped or referenced setTimeout
calls. I did this because I have an object factory that creates
multiple objects and those objects need to delay a few calls on
themselves at a certain point in time.

This code works fine for normal objects. However, my issue occurs if
at any point, an event object is passed across in IE.

It seems, that events methods and variables in IE are PRIVATE (!)
after the initial callstack has been finished.

The following is the code required to view this bug(?) in IE, and
success in FF. Code:

View 3 Replies View Related

Make A List Of Hyperlinks That Users Can Customize And Save As A Cookie By Clicking A Button And Automatically Retrieve The Cookie

Jan 26, 2011

Can I make a list of hyperlinks that users can customize and save as a cookie by clicking a button and automatically retrieve the cookie so it remembers their list next time? This is kind of what I want to do:

[Code]...

View 1 Replies View Related

Cookie Editing - Using - Only Displays Certain Text If The Cookie Is A Certain Number

Apr 30, 2009

I am making a sort of text based game (Just a hobby) I like to do that sort of thing. So, anyway, considering all I can really do is code HTML, and very, very light javascript, I kinda need some help.

I basicly know how to do everything except affect & Use the cookies. So what I need to do with them is to

#1.) Have a code to change the cookie number, say... on the click of a button.

#2.) Have a code where it only displays certain text if the cookie is a certain number.

I cant code JS and have no idea how hard/easy this is.

If it is insanely hard & needs a master coder, just tell me and ill take it off. I dont want to be wasting anyones time.

View 2 Replies View Related

IE6 Always Rejects A Particular Cookie Regardless Of Privacy/cookie Setting

Jul 23, 2005

I have an embedded system with a web interface. One of the web pages
has a small JavaScript program that, when run on IE6, always displays
the message that cookies need to be enabled:

if (document.cookie.indexOf('asm_session') == -1)
{
document.cookie = 'asm_session=0'
if (document.cookie.indexOf('asm_session') == -1)
{
document.write("Advanced System Management access requires
cookies to be enabled."+'<br><br>');
}
}

This problem only occurs with IE6, not Mozilla. It also only happens
on some of the embedded systems, but this problem exists for everyone
running IE6.

The problem isn't limited to the Javascript code, either. On another
web page from this embedded system, a cookie is set the normal way,
via the HTTP header. This cookie is also rejected.

When I display any page that attempts to set a cookie, IE6 displays
the blocked icon and says that cookies on that URL are blocked.
However, I have set all privacy and cookie options to their most
permissive. I've spent the past hour changing every option I can find
that's even remotely related to cookies and privacy, and nothing
changes. Does anyone have any idea what's going on?

View 1 Replies View Related

Retrieving Cookie Data Through Document.cookie

Jul 20, 2005

In my web application we are able to store large data in the browser
cookie keeping in mind the limit of 300 cookies per cookie file, 20
keys per cookie per domain and 4KB max size of each cookie. We are
unable to retreive this large amount of data immediately after storing
through document.cookie in IE browser (The same works fine in
Netscape).

Is there any limit on the size of the data that can be retreived using
document.cookie in IE browser? Could you please suggest a solution to
this problem I am facing.

View 1 Replies View Related

Set A Cookie In Cookie Directory But Not Working

Apr 9, 2010

I am trying to set a cookie in my cookie directory but this is not working.

document.cookie = "username=John;
expires=15/02/2015 00:00:00";

View 6 Replies View Related

How To Get The Num Of Days Absent Using C#

Jul 20, 2005

How to get the num of days absent using c# when start date and end date
are the date format is like this 12/24/12

View 2 Replies View Related

Days In The Week

May 8, 2006

I have a marquee in my site and and I have 7 corresponding html pages for 7 days of the week. I would like to have a day detection so (e.g) saturday.html will go in my iframe on my hompage ...

View 6 Replies View Related

Checking X Days Out

Aug 5, 2003

I need some JS code that will let me check and see if the date the user enters is within certain guidelines. ie...(no less than 2 days out and no more than 90 days out.)

Someone was kind enough to give me this code, but I can't get it to work correctly. Everything always returns false. If I am reading this write, if it returns false, then the conditions are not met.

Any ideas?

function compareDates(myDate, min, max)
{
var now = new Date().getTime();
var then = new Date(myDate).getTime();
var diff = (now - then) / 86400000;
var valid = true;

var min = min * 86400000;
var max = max * 86000000;

if (diff <= min || diff >= max) {
alert(diff + " " + min + " " + max);
return false;
}
return valid;
}
new compareDates("08/10/03", 2, 90);

View 2 Replies View Related

How To Add No. Of Days To Date

Feb 21, 2006

I am using 2 text boxes in form, in first text box i need to enter a date, in second text box i need to enter no. of days,at onblur event of second text box , i need to add value in second text box to first text box,

View 1 Replies View Related

Past 7 Days

May 23, 2006

I'm wondering how I can figure out what the past seven days were and loop through them to output?

View 7 Replies View Related

Adding Days To Date

Sep 16, 2009

I have a textbox with a date formatted 'dd/mm/yyyy'. I want to be able to add days to the date so that the month ticks over if the days exceed the days in the month and the year also if the month value passes 12. Currently I have the below. This adds to the days but will not tick over the month.

<html>
<head>
<script type="text/javascript">
function calDate() {
var dateArr = document.getElementById('testinput').value;
var myDate = new Date();
[Code]....

View 10 Replies View Related

Add 5 Days To A String Not Working

Mar 8, 2011

I have this string

var start = $('[name=invoicedate]').val();
alert('start'); // 2010/01/01

how can I add five days to have the following?

alert('start'); // 2010/01/10

Tried var start = new Date(year, month, day+5); but seems not work

View 3 Replies View Related

Age In Years To Age In Days Calculator?

Apr 14, 2011

I have to code something where the input would be the age (in years) and the output would be the age (in days). I'm not sure what I did wrong, but it's not working,

[Code]...

View 4 Replies View Related

Specify A Different Message For Days And Times

Apr 7, 2009

I have been tasked with creating a small tool that will allow messages to be copied and pasted from a form. I have the form and have the basics of what I need but I am stuck with dates and times.

Long story short, I am trying to figure out how to get a message to be displayed on a page using the document.write depending on the following criteria:

If the day and time are monday to Friday 08:00 to 15:00 the message will state that the next update will be in 2 hours time from when this update was posted

If the day and time are monday to thursday 15:00 to 18:00 the message will state that the next update will be at 09:00 the next working day (i.e. if it's 16:30 on a tuesday, the next update will be at 09:00 on wednesday etc)

If the day and time are friday 15:00 to 18:00 the next message will state that the next update will be at 09:00 the next monday.

View 2 Replies View Related

Datepicker Excluding Certain Days?

Jan 7, 2011

Is it possible to have a datepicker which excludes certain days? I'm looking for a script which I can set what days a user can select. Ideally I would like to be able to set a few specific timeslots along with this.

View 19 Replies View Related

Adding Days To Current Date?

Oct 26, 2010

I am trying to add a calculated number of days to the current date. Here is my code:

Code:

var tempday=new Date();
var adddays=1+(7-tempday.getDay());
tempday.setDate(tempday.getDate()+adddays);

In this case I am calculating the number of days until the next Monday. Since today is Tuesday, it calculates 6 which is correct. The resulting date should be 11/1/2010. However, the month is not wrapping because the result is 10/1/2010. How do I fix this?

View 2 Replies View Related

Subtract N Days From Current Date?

Nov 10, 2010

I have the following function that will subtract n number of days from todays date. The problem is that it always returns the the wrong calculate date. The month is wrong.

see if you can spot my mistake:

Code:

function returnDate(ndays){
var dayOfTheWeek = now.getDay();
now.setTime(now.getTime() - nDays * 24 * 60 * 60 * 1000);
alert(now); // returns current date
alet(now.getYear() + "/"+now.getMonth()+"/"+now.getDate()) // returns new calculated date
}

View 5 Replies View Related

Disable First 3 Days Of Popup Calendar

Aug 9, 2010

I need to disable the first 3 days of a popup calendar so that users can only select a date which is 3 days in advance to the present date. I dont really know javascript. Calendar code can be found below.

[Code]...

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved