Connect with Facebook Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > JavaScript and CSS

JavaScript and CSS Extensible Markup Language, Java Script, and CSS questions here.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-09-2006, 02:36 AM
John's Avatar   
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 5,306
Blog Entries: 24
Rep Power: 20
John is just really niceJohn is just really niceJohn is just really niceJohn is just really niceJohn is just really nice
Send a message via AIM to John Send a message via MSN to John
Default Creating Cookies

how can i create a cookie in java script? i basically want a function that does the equivilant of this in php

PHP Code:
setcookie('clicked'"TRUE"time()+99999
what i intend is to have a link, and when it is clicked, the javascript create a cookie

HTML Code:
<a href="http://www.google.com" onclick"CookieClick()">gooooogle</a>
or something like that

CookieClick() would then create the cookie
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-09-2006, 09:11 AM
Blaze's Avatar   
Programmer
 
Join Date: Jun 2006
Posts: 117
Rep Power: 0
Blaze is an unknown quantity at this point
Default

You access them by the document.cookie

Code:
document.cookie =
  'ppkcookie1=testcookie; expires=Thu, 2 Aug 2001 20:47:11 UTC; path=/'
1. First the name-value pair ('ppkcookie1=testcookie')
2. then a semicolon and a space
3. then the expiry date in the correct format ('expires=Thu, 2 Aug 2001 20:47:11 UTC')
4. again a semicolon and a space
5. then the path (path=/)


From: http://www.quirksmode.org/js/cookies.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-09-2006, 12:27 PM
John's Avatar   
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 5,306
Blog Entries: 24
Rep Power: 20
John is just really niceJohn is just really niceJohn is just really niceJohn is just really niceJohn is just really nice
Send a message via AIM to John Send a message via MSN to John
Default

that seems easy enough..also rather then specifying a specific date, would it be possable to create it so the cookies expire 24 hours after they are created (dynamically)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-12-2006, 09:02 PM
Void's Avatar   
Programming Expert
 
Join Date: Jun 2006
Posts: 410
Rep Power: 14
Void is on a distinguished road
Default

Yes, here is some code:

Code:
var expireDate = new Date()
expireDate.setHours(expireDate.getHours()-10)
Add it here:

Code:
document.cookie =
  'ppkcookie1=testcookie; path=/; expires=' + expireDate.toGMTString();
However, this is untested. I just took it from some other code on the web.
__________________
Void
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Clock AfTriX VB Tutorials 1 05-08-2009 10:33 AM
Creating an analog clock with ActionScript AfTriX Tutorials 2 01-07-2007 02:19 AM
Cookies dirkfirst HTML Programming 10 01-06-2007 04:11 AM
Creating a backup script NeedHelp General Programming 3 09-07-2006 05:14 AM
Creating Tables leon Database & Database Programming 2 06-12-2006 09:02 AM


All times are GMT -5. The time now is 08:15 PM.

Freelance Jobs

XML/XSL: Need code for Book with Chapers using XML
Create an XML file for a book of your creation, and a basic CSS file that will format it to display ...
Earn: $40.00


C++/C: Simple firework cue sequencer
What I require is a rework of a simple cue sequencer. I have a piece of hardware (an Arduino boar...
Earn: $50.00


HTML/XHTML: Menu Rework - ASCIIBin
I'm placing this in the HTML/XHTML section of the Freelance site but you are not limited to HTML. Wh...
Earn: $20.00



CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%

Ads