JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 5th, 2002, 02:20 PM
poring poring is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Posts: 68 poring User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 39 m 9 sec
Reputation Power: 7
Cookies and Javascript.

I'm trying to figure how javascript handles cookies. Here are my questions:


- Is it possible for a javascript to read a cookie that was set trough php?

- How do you set a cookie in javascipt? Is there an aquivalent of the php function setcookie() ?

How do you read cookies with javascript? I know in php you just type a variable wich is the name of the cookie, is it the same in JS?


Finaly, if someone know a good, complete tutorial on cookies with JS, please tell me!

Thanks

Reply With Quote
  #2  
Old August 6th, 2002, 11:50 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 19
Yes, javascript and php and asp and any cookies are interchangable, readable and settable by every language.

javascript:

document.cookie = "cookiename=cookievalue"

In javascript the retrieving of cookies is a bit difficult. What you actually get returned is a string representing every cookie. So to extract cookie info you need to substring it as such:

var cookieVal = document.cookie.substring(document.cookie.indexOf("cookiename") + 11, document.cookie.length)

Yup, it's crap, so you're better off using PHP/ASP to extract the cookie info.
__________________
- Sorted!

www.ppfuk.com - Free Photo Sharing

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Cookies and Javascript.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT