# Retrieving data from a cookie

**URL:** <https://forum.kirupa.com/t/retrieving-data-from-a-cookie/289239>\
**Category:** programming\
**Created:** [May 27, 2009, 9:29pm UTC](https://forum.kirupa.com/t/retrieving-data-from-a-cookie/289239 "2009-05-27T21:29:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fido\_glc](https://avatars.discourse-cdn.com/v4/letter/f/3da27b/32.png) [@fido\_glc](https://forum.kirupa.com/u/fido_glc)\
**Post date:** [May 27, 2009, 9:29pm UTC](https://forum.kirupa.com/t/retrieving-data-from-a-cookie/289239/1 "2009-05-27T21:29:55Z")

</div>

Hello.

I have a problem with using a cookie in Flash and I need some help. I don’t know too much about cookies so I am looking forward to your help.

What I need is to retrieve the username from a cookie into Flash. I am using LoadVars to communicate with a PHP file that will echo the username.

The problem is with the PHP file that should output the username from the cookie.

Here is the simple PHP code that I have tried:

```php

$user = $_SESSION['username'];
echo "user=".$user;

```

I have also tried the following:

```php

$user = $_COOKIE['username'];
echo "user=".$user;

```

Are any of these correct ? Is there anything else that I need to do ? I am sure that it is something rather simple in the end.

Again, what the PHP code needs to do is retrieve the username with the id of “username” from a cookie.

Thank you.
