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

Posted on 2005-04-18
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


    Author Comment

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

    Accepted Solution

    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:

    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: 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

    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 run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    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 …

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now