Hi,
I've written my own JavaScript and used a couple of codes to set and get cookies from the net I found.
When I set the cookie I can see it in my browser, it is set with the right value and expiration date etc. The only problem I'm getting is when I retrieve the cookie the value is always NULL. - // ==UserScript==
-
// @name Utopia Login/Loged
-
// @namespace http://games.swirve.com/utopia/login.htm
-
// @description Logs your Utopia login
-
// @include http://games.swirve.com/utopia/login.htm
-
// @include http://u1.swirve.com/enter.cgi
-
// @include http://u1.swirve.com/logout.cgi?
-
// ==/UserScript==
-
-
var cookie;
-
var loggedIn = false;
-
var lastLoginDate;
-
var lastLoginTime;
-
-
var currentLocation = location.href;
-
-
if (currentLocation == "http://games.swirve.com/utopia/login.htm" && loggedIn == false)
-
{
-
cookie = readCookie("utopiaLoginTimer");
-
window.alert("Login page : cookie_value: " + cookie);
-
-
if (cookie)
-
{
-
window.alert("Last login date and time: " + cookie);
-
}
-
}
-
else if (currentLocation == "http://u1.swirve.com/enter.cgi")
-
{
-
window.alert("Logged in");
-
loggedIn = true;
-
}
-
else if (currentLocation == "http://u1.swirve.com/logout.cgi?")
-
{
-
window.alert("Logged out");
-
loggedIn = false;
-
-
var date = new Date();
-
date.setTime(date.getTime()+(1*24*60*60*1000));
-
-
var expires = date.toGMTString();
-
createCookie("utopiaLoginTimer", "test_something", 5);
-
}
-
-
function createCookie(name,value,days)
-
{
-
if (days)
-
{
-
var date = new Date();
-
date.setTime(date.getTime()+(days*24*60*60*1000));
-
var expires = "; expires="+date.toGMTString();
-
}
-
-
else var expires = "";
-
document.cookie = name+"="+value+expires+"; path=/";
-
-
window.alert("Cookie created : value : " + value);
-
}
-
-
function readCookie(name)
-
{
-
var nameEQ = name + "=";
-
var ca = document.cookie.split(';');
-
for(var i=0;i < ca.length;i++)
-
{
-
var c = ca[i];
-
while (c.charAt(0)==' ') c = c.substring(1,c.length);
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
-
}
-
return null;
-
}
-
-
function eraseCookie(name)
-
{
-
createCookie(name,"",-1);
-
}
This is a small script that I'm using with GreaseMonkey for Firefox.
All the If statements work fine and every gets set and displayed but the cookie value is always returned as NULL?
Thanks
P.S. How do I get my current system time, I am GMT+10, the date that comes up in the windows.alert is tomorrows date and 1PM whereas I am at 12AM now.
2 3194
Just found out, the code works on:
http://games.swirve.co m/utopia/login.htm
but not on:
http://u1.swirve.com/logout.cgi?
Anyone know the reason why this might be?
Just found out, the code works on:
http://games.swirve.co m/utopia/login.htm
but not on:
http://u1.swirve.com/logout.cgi?
Anyone know the reason why this might be?
I think this "http://u1.swirve.com/logout.cgi?" will be "http://u1.swirve.com/logout.cgi"
Simply do remove the "?" then see what happens.
Debasis Jana
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Phil Powell |
last post by:
URL: http://valsignalandet.com/cookiegrab.php?name=valIdentifier
This page produces a cookie value and sends it back as HTML using PHP
and Javascript to obtain it. This URL will be used as the value for a
URLConnection object in a Java class to obtain the results of this
page to get, of all things, a cookie value.
Simply put: it's the ONLY way I know of where I can use Java to
ultimately obtain a cookie since this is an application...
|
by: Sucpraran |
last post by:
We are using Cookies in our application to track user session. It
works 95% but fails in occations. We could not find any pattern for
this. Below is the code to Set and Get cookies. In the occations when
it fails, we get nothing in getCookie as if cookie is not set. We
verified Browswer Setting and all of them accept cookies. We try to
find a pattern with Broswer types/versions and OS types/versions but
could not come with a pattern.
...
|
by: Connie Walsh |
last post by:
Hi:
I gleaned a javascript off of the web:
http://www.hypergurl.com/popup.html
that sets a cookie everytime someone visits your site. If it is the
first visit in x number of days then a popup will appear. It would be
great for my application but I can't get it to work. Here is my code:
|
by: socialism001 |
last post by:
I'm trying to store a value in a cookie but its not working. Can
anyone see what I might be doing wrong.
Thanks,
Chris
~~~~~~~~~~~~~~~~~~
<script language="javascript">
if(document.cookie.indexOf("beenHere1=true")!=-1)
else
|
by: Marco Krechting |
last post by:
Hi All,
I have a page with a list of hyperlinks.
I want to save information in a cookie about the fact that I entered an
hyperlink or not.
When I click one of the hyperlinks I want this stored in a cookie and a
small bullit shown in front of the hyperlink,
so when I reload the page I can immediately see which hyperlinks I already
visited that day.
| |
by: Mike |
last post by:
I have a web application that the forms authentication cookie is not expiring correctly. When I look at the trace information of a newly requested page after the session and forms authentication have expired the forms authentication cookie is assigned a new value. I am never redirected to the login page after my initial login. If I access the site from http://localhost/myapp instead of myapp.domain.com the cookies expire correctly. The cookie...
|
by: CR1 |
last post by:
I found a great cookie script below, but don't know how to make it also pass the values sent to the cookie, to a querystring as well for tracking purposes. Can anyone help? If there was a way to simply pass the values in a cookie to the querystring that would be even easier, but from what I've been able to tell, cookie values can't be passed to a querystring.
I'm sure the answer will help alot of others who are using this script, and would...
|
by: bkendra5 |
last post by:
I am volunteering at a hospital and working on the intranet. They want an option to have a pop up message but they only want it to pop up once or twice, and then be able to change the content and have it re pop-up.
Example: week1 how to properly wash your hands
Week2: system wide meeting on thursday dont forget. etc etc..
I am not very good in Java. but this is what i have so far. Can anyone point me in the right direction. Greatly...
|
by: =?Utf-8?B?Qkw=?= |
last post by:
if (Request.Browser.Cookies)
{
// Cookies supported
}
else
{
// Web browser not supports cookies
}
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |