Lost Password?

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

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

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   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,237
Last Blog:
Passwords
Credits: 877
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
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

Sponsored Links
  #2 (permalink)  
Old 10-09-2006, 09:11 AM
Blaze's Avatar   
Blaze Blaze is offline
Programmer
 
Join Date: Jun 2006
Posts: 117
Credits: 1
Rep Power: 9
Blaze is on a distinguished road
Default

You access them by the do***ent.cookie

Code:
do***ent.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   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,237
Last Blog:
Passwords
Credits: 877
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
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   
Void Void is offline
Programming Expert
 
Join Date: Jun 2006
Posts: 410
Credits: 0
Rep Power: 11
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:
do***ent.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 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 Clock AfTriX VB Tutorials 0 01-04-2007 01:53 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 01:30 AM.

Contest Stats

Xav ........ 1322.18
MeTh0Dz|Reb0rn ........ 1053.7
morefood2001 ........ 879.43
John ........ 877.37
marwex89 ........ 869.98
WingedPanther ........ 830.24
Brandon W ........ 735.07
chili5 ........ 309.39
Steve.L ........ 239.84
dcs ........ 216.02

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads