Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

accessing a filemaker cookie with PHP...

Featured Replies

More of a PHP question maybe but...

I think this might be down to what I set the cookie path and domain as but...

We host some databases on the web and the domain is dealer-world.com

We have our main webspace with our host, but also some PHP enabled webspace on a different server at dealerworld.plus.com

I have a couple of cookies set using the FMP-SetCookie CDML command, but I don't use the path or domain options for the cookie.

Is it possible for me to access those cookies from my PHP website, even though the domain is different?

I want to have as few pages running from filemaker as possible, to reduce loads and keep only the actual CDML format pages on our filemaker web server.

What's the PHP syntax I would use to read the value of those cookies??

FileMaker Version: Server 5

Platform: Windows 2000

As far as I know you will not be able to access them because they are from a different domain.

Can you pass the data to the php scripts as GET or POST values?

Good Luck.

Garry

  • Author

Not sure about that.

Would I be able to access them if I moved our PHP platform over to our main domain www.domain.com?

So our cdml pages are served from web.domain.com and our php pages are from www.domain.com?

Would that work? As the domain is domain.com in both cases?

FileMaker Version: Server 5

Platform: Windows 2000

Hi, I'm setting cookies in PHP and FMPro and each read and write OK.

Because most web browsers are set to only allow cookies that are read back by the original server, you must set and read them from the same domain. It works OK if you're using different ports for webserver and FMPro.

"What's the PHP syntax I would use to read the value of those cookies" - just the regular php ones, like

if($_COOKIE['mycookie'] == "a value")

or

$myVariable = $_COOKIE['mycookie'];

- I don't think either PHP or FMPro can tell how the cookie's been set

regards, jeff

  • Author

So this will work from my main website www.domain.com even though the cookie has been set at test.domain.com?

Excellent!

Thanks

Hi, no, any cookie can only be read by the domain that set it. So you can have FMPro and Apache both setting and reading cookies on the same server, but not different ones. Even subdomains (like webserver.mydomain.com and data.mydomain.com) don't work, but "mydomain.com" and "mydomain:591.com" does work and is the way I've used it between php and FMPro.

regards, jeff

  • Author

So so long as I specify in the domain attribute of [FMP-SetCookie domain.com it should be able to be read by pages at www.domain.com and at remote.domain.com?

FileMaker Version: Server 5

Platform: Windows 2000

Hi, I tried that and if the domain is not a correct one for that server it errors and does not set.

I think this is a browser security thing and you have to set and read from the same server. Normally, you don't need to specify domain a all as the browser picks it up.

regards, jeff

  • Author

But what about for subdomains, of the same domain?

As technically the domain is the same! they are hosted on different

servers though.

old.domain.com hosted at our offices, and www.domain.com hosted at our ISP.

Does the browser just pick up domain.com in both cases, or will it pick up www.domain.com and old.domain.com?

Hi, again it needs to be on the same server. Subdomains on different servers don't work (I've tried it). I think what is being looked at is the IP address.

Jeff

  • Author

Pants!

That's pretty annoying.

Obviously a limitation or I suppose a security feature of cookies..

Oh well - time to find a work around!

Thanks anyway

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.