[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


A cookie set by php, can it b read by javascript and vica versa?

Posted on 2005-04-18
Medium Priority
Last Modified: 2008-02-26
the title really says it all, if i set a cookie with php, can javascript read it out and the other way around?
Question by:jesuisperdu
LVL 33

Expert Comment

ID: 13810406

Author Comment

ID: 13810671
would you or someone else be as kind as to provide me a small example? :P
LVL 27

Accepted Solution

Diablo84 earned 200 total points
ID: 13811239
What would you like an example of, setting a cookie with PHP / reading a cookie with PHP / setting a cookie with JS / reading a cookie with JS?

I can cover the first two for you...

if you set the cookie "mycookie" using:


You would read it by referencing the COOKIE array, eg:

echo $_COOKIE['mycookie']; //outputs myvalue

Direct your attention here for more: http://us3.php.net/manual/en/function.setcookie.php

As for the latter two, you would be better off asking the folks in the JavaScript TA... as i recall the code for handling cookies client side is quite lengthy. Your alternative is a quick google search: http://www.google.com/search?hl=en&q=read+a+cookie+with+javascript My expertise is limited in the field of JS i am afraid.

Given that snoyes_jw's post answered your original question please do not accept my comment as an answer :)

LVL 14

Expert Comment

ID: 15990313
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: Diablo84 {http:#13811239}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

EE Cleanup Volunteer

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month20 days, 5 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question