Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7979 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Hi ppl. This is my first post here, so please, be gentle.

I have a cookie implementation on JavaScript working on a web site, so that when a user tries to access a certain page of it with a bookmark, it detects if the cookie exists and if not, then a redirect is performed. However, I've been asked to evolve this solution, so that I could store additional info of the user in the cookie and therefore pass it to a user login database for statistical purposes. This is where the prob begins. Here is a sample code of an html for info detection and cookie storage:

<html>

<head>

<title></title>

<script language="javascript">

function detect () {

internalCode=navigator.appCodeName;

browserName=navigator.appName;

browserVer=navigator.appVersion;

headerInfo=navigator.userAgent;

os=navigator.platform;

document.write("Your browser tye is "+internalCode+"<br>");

document.write("You're browsing using "+browserName+"<br>");

document.write("The Web Browser Version is "+browserVer+"<br>");

document.write("Header: "+headerInfo+"<br>");

document.write("OS platform is "+os);

}

detect ();

function setCookie(NameOfCookie,expiredays)

{

var ExpireDate = new Date ();

ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

document.cookie = (name=NameOfCookie +"; values =" + escape(navigator.appName+"|"+navigator.appVersion+"|"+navigator.platform) +

((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()));

}

setCookie ('cracker',1) // cookie name, days 'till expire = 1

document.write("<br>"+document.cookie) // writes all of the cookie to screen

</script>

</head>

<body>

</body>

</html>

Does anybody know how I can import this info into an DB in FM? I can't get the examples I've got here to work. The mere html fails.

I'm near mental meltdown here.

wink.gif Thx in advance

J

Posted

Try this:

document.cookie = "name=" + NameOfCookie + "; values=" + escape(navigator.appName + "|" + navigator.appVersion + "|" + navigator.platform) +

((expiredays == null) ? "" : ("; expires=" + ExpireDate.toGMTString()));


Then on the page you want to use, to add this info to the DB, you would assign the cookie values to <input> tags. You can use either Javascript or CDML ([FMP-Cookie]) to do this.

All the best.

Garry

This topic is 7979 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.