Cookie Path issue

kiz_0987

Joined: 2005-02-27
Posts: 189
Posted: Thu, 2006-03-16 04:03

I am working on a G2.1 version of the Drupal embed code and have an issue relating to the cookie path. In the G2.0 version the cookie path was never touched by the Drupal code.

For example:
Drupal is at http://www.example.com/testsite/drupal
Gallery2 is at http://www.example.com/testsite/gallery2

g2Uri is /testsite/gallery2/
embedUri is /testsite/drupal/?q=gallery

Cookie path is unset in Gallery2 admin page.

When I look at the cookies after being logged in I see one GALLERYSID with path /testsite/drupal/. This causes some restricted photos to not be displayed, presumably as the path is wrong. Is this what would be expected? When I manually set the G2 cookie path to /testsite/ all works OK.

The integration Codex docs suggest that setting the cookie path is an optional step, but is this true? If it is mandatory, then I'll need to "compare the path of the emApp with the G2 path and the longest common part should be used for the cookie path" (from Codex). Is there a simple robust way to do this in PHP? Can this be added to the G2EmbedDiscoveryUtilities code?

Thanks for your help.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2006-03-18 09:12

set the cookie path in site admin -> general to / or to /testsite/ .
then clear your browser cookie cache.

setting the cookie path is optional if the integration is ok. if the integration doesn't handle rewrites or so correctly, you need to do it manually.

 
kiz_0987

Joined: 2005-02-27
Posts: 189
Posted: Sat, 2006-03-18 11:06

Ah, maybe I'm starting to understand this. Let's say that there is no URL rewriting. With no cookie path set the G2 ImageBlock will return something like:

  <a href="/testsite/drupal/?q=gallery&amp;g2_itemId=34" >
  <img src="/testsite/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=35&amp;g2_serialNumber=2&amp;g2_GALLERYSID=f09e978cd34a82d202a38ad89cc3fb18" width="113" height="150" id="IFid1" class="ImageFrame_image" alt="DSCN2952.JPG" longdesc=""/>
      </a>

And the path in the cookie with this ID is '/testsite/drupal/' so is not valid for the Download item and so the thumbnail is not displayed. I cannot see any way with any integration code without URL rewrite to make this work without changing the cookie path. With URL rewrite and a rule for download item I can see how it could work.

Is this correct? If so, maybe the integration code docs could be modified to clarify this. Thanks.