---
title: "Facebook API: Undocumented Cookie Management REST APIs"
description: The Facebook API does have a way to set and get cookies, but it is in beta so is not currently part of the FB PHP libraries. I found it out by searching through forums, by trial-and-error, and on the FB Beta docs page. There are 2 functions available:
image: https://blog.thoughtlabs.com/hubfs/Imported_Blog_Media/Facebook-Developer-Mar-20-2024-06-51-16-4635-PM.png
---

<https://www.thoughtlabs.com/>

- [About Us](https://www.thoughtlabs.com/about.html)
- [Our Services](https://www.thoughtlabs.com/services.html)
- [Our Clients](https://www.thoughtlabs.com/clients.html)
- [Our Blog](https://blog.thoughtlabs.com/blog/)
- [Our Book](https://www.thoughtlabs.com/book.html)
- [Free Resources](https://www.thoughtlabs.com/free-resources.html)
- [Speaking](https://www.thoughtlabs.com/speaking.html)
- [Contact Us](https://www.thoughtlabs.com/contact.html)

<https://twitter.com/thoughtlabs> <https://www.facebook.com/thoughtlabs>

![](https://blog.thoughtlabs.com/hubfs/Imported_Blog_Media/Facebook-Developer-Mar-20-2024-06-51-16-4635-PM.png)

# Facebook API: Undocumented Cookie Management REST APIs

![Cappy Popp](https://blog.thoughtlabs.com/hs-fs/hubfs/author-cappy-popp.jpg?width=50&height=50&name=author-cappy-popp.jpg)

Written by [Cappy Popp](https://blog.thoughtlabs.com/blog/author/cappy-popp)

on Feb 14, 2008

![Facebook-Developer](https://blog.thoughtlabs.com/hubfs/Imported_Blog_Media/Facebook-Developer-Mar-20-2024-06-51-16-4635-PM.png)

The Facebook API does have a way to set and get cookies, but it is in beta so is not currently part of the FB PHP libraries. I found it out by searching through forums, by trial-and-error, and on the FB Beta docs page. There are 2 functions available:

```
  data.getCookies( user_id, cookie_name );
  data.setCookie( user_id, cookie_name, cookie_value, expires, path );
```

To use these functions from PHP I simply wrapped them in functions that call the RESTful APIs correctly:

```
// to get cookies for a given user (optionally by name):
function get_cookie($uid, $name=null) {
  global $facebook;
  return $facebook->api_client->call_method('data.getCookies', array('uid' => $uid, 'name' => $name) );
}

// to set a cookie for a given user:
function set_cookie($uid, $name, $value, $expires=null, $path=null){
  global $facebook;
  return $facebook->api_client->call_method('data.setCookie', array('uid' => $uid, 'name' => $name,
    'value' => $value, 'expires' => $expires, 'path' => $path) );
}
```

 Topics: [Programming](https://blog.thoughtlabs.com/blog/tag/programming)

**About the author:**

![Cappy Popp](https://blog.thoughtlabs.com/hubfs/author-cappy-popp.jpg)

#### [Cappy Popp](https://blog.thoughtlabs.com/blog/author/cappy-popp)

Cappy Popp has decades of software development experience and has successfully designed and implemented digital strategies for dozens of companies in multiple markets. Cappy specializes in digital strategy, analytics, and monitoring and is the co-author of the acclaimed book, Essential Facebook Development.

Find me on: <https://facebook.com/cappypopp> <https://linkedin.com/in/cappy> <https://twitter.com/cappypopp>

 Copyright © 2026 Thought Labs, LLC. All rights reserved. Website Design & Development by [Metropolis](https://www.metropoliscreative.com)  |  [privacy policy](https://www.thoughtlabs.com/privacy.html)  |  [cookie policy](https://www.thoughtlabs.com/cookie-policy.html)  | 

cookie settings

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Cappy Popp",
    "url" : "https://blog.thoughtlabs.com/blog/author/cappy-popp"
  },
  "dateModified" : "2024-03-20T18:53:13.825Z",
  "datePublished" : "2008-02-14T05:00:00.000Z",
  "headline" : "Facebook API: Undocumented Cookie Management REST APIs",
  "image" : [ "https://blog.thoughtlabs.com/hubfs/Imported_Blog_Media/Facebook-Developer-Mar-20-2024-06-51-16-4635-PM.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.thoughtlabs.com/blog/facebook-api-undocumented-cookie-management-rest-apis",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.thoughtlabs.com/hubfs/Email/TL%20Logo%20Wide.png"
    }
  }
}
```