473,378 Members | 1,426 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Check for cookie on page load and redirect to another page if found

I am trying to add a code to my contact page that checks for a cookie named NewCookie, and if this cookie is found it will redirect the user to another page called alreadysubmitted. I have tried everything I can,.
Dec 1 '13 #1
2 1664
Dormilich
8,658 Expert Mod 8TB
so, what was it that you have tried?
Dec 1 '13 #2
I have tried the onload command and tried to break down ones like this but I am very new to javascript and I believe with all the site and things I have tried I have made myself very confused.



Expand|Select|Wrap|Line Numbers
  1. function getCookie(NewCookie)
  2. { if (document.cookie.length > 0)
  3. { begin = document.cookie.indexOf(NewCookie+"=");
  4. if (begin != -1)
  5. { begin += NewCookie.length+1;
  6. end = document.cookie.indexOf(";", begin);
  7. if (end == -1) end = document.cookie.length;
  8. return unescape(document.cookie.substring(begin, end)); }
  9. }
  10. return null;
  11. }
  12.  
  13.  
  14.  
  15. function setCookie(NewCookie, Website cookie value, expiredays)
  16. { var ExpireDate = new Date ();
  17. ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
  18. document.cookie = NewCookie + "=" + escape(value) +
  19. ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
  20. }
  21.  
  22.  
  23.  
  24. function delCookie (NewCookie)
  25. { if (getCookie(NewCookie)) {
  26. document.cookie = NewCookie + "=" +
  27. "; expires=Thu, 30 Dec 2013 00:00:01 GMT";
  28. }
  29.  
  30. }
  31.  
Dec 1 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Savas Ates | last post by:
can i send my page title to another page.... like this response.redirect "xx.asp?title"&mytitle mytitle= what can bee... i dont want to write manually my title any method to learn title in...
2
by: Dave | last post by:
Can I determine if an array of image links is already in memory without using cookies or a hidden frameset? Scenario: visitor starts with Home page, images (links) for navigation pre-load no...
0
by: Frank 'Olorin' Rizzi | last post by:
Hello everyone. This is quite convoluted, but I'll try to make it simple. I have a couple of bottom-line questions (I guess): 1~ what happens between the Page_Load routine in the code behind...
5
by: venky | last post by:
Hi, I have a question, i have a web control in my web page. Let say i have page pag1.aspx and control.ascx and page1 contains control. I have written code on the page load of page and also the...
2
by: Dave | last post by:
I'm fairly new to this ASPX/OLEDB stuff. I have an OleDbDataReader in one ..aspx page. I do a Server.Transfer to another page. Is it possible to make it so that the data in the OleDbDataReader is...
3
by: kirankumarkmca | last post by:
How to set Focus on Textbox in Asp.net while Page Load event Another How to play songs in Vb.net
6
by: Steve Richter | last post by:
what with the website solution structure not having a namespace, how does the class of one website .aspx page class reference the class of another page in the same website? I have two pages....
2
by: Bruce A. Julseth | last post by:
I have a decision tree where I need to load different pages depending upon the conditions. My problem is I don't know how to quit a page and load a new page. How do I quit one page and start...
0
by: talhakarkun | last post by:
hi all i am using lightbox in my application. through lightbox i am open new window and add new recored in database.. the problem is that when i am close my popup window at that time the data...
0
by: Anupam Jana | last post by:
Hello All, I want to redirect to some other directory page after displaying JavaScript alert message in ASP.net in a page. For that I tried bellow code in our application...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.