SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    unable to print cookie in php.....

    Hi There,


    I am trying to set cookie for my website to block some countries.

    I am setting cookie something like this.

    setcookie ("mynewblockingcookie","1",time()+31536000,'/');

    And this is how I am trying to print the cookie.

    $mycookie = $_COOKIE["mynewblockingcookie"];

    PROBLEM.

    the problem is...when I printing cookie in admin folder/panle...its working and showing value 1.

    But when I tried to print it on my root folder (User End), it shows nothing.

    Please let me know where I mistook? I checked the cookie in browser setting....its showing, its printing in admin section, but it shows nothing on user end.

    Thanks in advance for your appreciable help.

    Thanks!!

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    Well your printing line isnt a printing line, it's an assigning line.
    Just to cover all the bases....
    #1: The admin folder/panel is on the same domain as the user end. (Everything before the third / in the URL is the same).
    #2: You havent misspelt the cookie name on the user end.
    #3: You're using an actual echo or print to display the cookie value
    #4: You're doing so in a place that is -visible- on your user end.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Star....

    I got it working.....actually I have to open my website in new tab once cookie is set.

    As in current tab cookie was not recognized...

    Its working...Thanks for your help!


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
  •