SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Extract cookie value created using javascript in another file.

    I am Lakshmi.Research scholar.I have a doubt in the usage of cookies in javascript.Normally in order to extract the cookie value we have to specify the corresponding cookie name.But I need automatic extraction.If i give a php file in which the cookies are created using javascript,all the cookies in that file should be extracted.Is it possible?

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You should be able to simply set it in javascript and get it in PHP using

    PHP Code:
    <?php

    echo $_COOKIE['cookie_name'];

    ?>

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Thanks for the reply.I need automatic extraction of cookies.The input will be the file name,the output should be the number and name of the cookies in that file.is it possible?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Santhana Lakshmi View Post
    Hi,
    Thanks for the reply.I need automatic extraction of cookies.The input will be the file name,the output should be the number and name of the cookies in that file.is it possible?
    No, that is not possible.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Santhana Lakshmi View Post
    I need automatic extraction.If i give a php file in which the cookies are created using javascript,all the cookies in that file should be extracted.Is it possible?
    You can use JS to read all the cookies visible in a given folder, if that's what you want.
    I think in PHP it would only be possible if you had an array of all names likely to be used, short of running a time-consuming brute-force search.
    Tab-indentation is a crime against humanity.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How to extract javascript coding from html file?

  7. #7
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Santhana Lakshmi View Post
    How to extract javascript coding from html file?
    I have no idea what you mean by that. Please be specific.
    Tab-indentation is a crime against humanity.

  8. #8
    SitePoint Member
    Join Date
    Feb 2011
    Location
    Virginia
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To retrieve all cookies for the current page, you can use the "document.cookie" property to get list of key=value pairs separated by semicolon.
    is that you are looking for?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •