homepage Welcome to WebmasterWorld Guest from 54.197.183.230
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
How to get the value of a Cookie?
How to get the value of a Cookie?
nimonogi

5+ Year Member



 
Msg#: 3626385 posted 1:11 pm on Apr 14, 2008 (gmt 0)

Hello,

How can i get the Value of a cookie?

Set the cookie:

setcookie("name", "value", time() - 3600);

Read the cookie:

(isset($_COOKIE["name"]))

I want to read the value not just the name.

Thanks in advance!

 

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3626385 posted 1:35 pm on Apr 14, 2008 (gmt 0)

try this to see what's in the cookie

echo '<pre>';
print_r($_COOKIE);
echo '</pre>';

Achernar

5+ Year Member



 
Msg#: 3626385 posted 6:21 pm on Apr 14, 2008 (gmt 0)

$_COOKIE["name"] is the value

nimonogi

5+ Year Member



 
Msg#: 3626385 posted 7:22 pm on Apr 14, 2008 (gmt 0)

This was easier than i thought :P

So, is this correct?

if (isset($_COOKIE["name"]))
{
$content = $_COOKIE["name"];
}

(If a cookies is set, $content gets its value)

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3626385 posted 7:32 pm on Apr 14, 2008 (gmt 0)

yes, it should be correct

try it and see

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved