The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 21, 2019, 01:58:20 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: retrieving all cookies for a domain  (Read 2312 times)
ratthing
Journeyman
***
Offline Offline

Posts: 75


View Profile
« on: December 10, 2007, 04:31:42 PM »

How can a PHP script access all the cookies for a given domain's paths?  I'm working on my test LAMP box, and have a set of scripts to set a cookie for the "/" directory.  I also would like to add a checkto see if there's a cookie for a WP user active.  The blog is under the directory, "blog".  Barebones code to try to see the WP cookies:
Code:
<?php
error_reporting
(E_ALL);
//start a session
session_name("cookiechk");
session_start("cookiechk");
$blog "/blog/";
print 
'<pre>'var_dump($_SERVER['HTTP_COOKIE']); print '</pre>';
?>
As a test, I log into my WP blog on the test box, verify the cookies are there (two WP session cookies, plus the logged in user cookie), then hit my script above in another tab. All I get back when the script runs is the session cookie for the "cookiechk" session.

Should I just be trying to retrieve the WP cookie directly instead?  I saw nothing in the PHP docs that referenced retrieving/viewing cookies by path.

Cluebats appreciated--
=RT=

Logged
ratthing
Journeyman
***
Offline Offline

Posts: 75


View Profile
« Reply #1 on: December 11, 2007, 11:24:56 AM »

Answering my own question here... D'oh!

Seems like you can only see cookies at your script's current path level and above, not parallel to your path.  I'll either have to add a bit of code to WP to create another cookie at the root level which my script can see, or skip the script check and have mod_rewrite do the check.

Have I mentioned I hate mod_rewrite.  It would appear I am going to continue to suffer it's horrors.
=RT=
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: December 11, 2007, 01:02:59 PM »

mod_rewrite is ugly as sin, but simply shithot. Ping more if'n you be having difficulties...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
ratthing
Journeyman
***
Offline Offline

Posts: 75


View Profile
« Reply #3 on: December 26, 2007, 10:24:26 AM »

I appreciate the offer, Perk.  Every time I think I'm starting to wrap my brain around mod_rewrite and actually grokking it, I read/see/test something else, and that brief glimpse of the light bulb shatters.  But I keep muddling through.  I have to say that jdMorgan over at webmaster world is the shizzle when it comes to mod_rewrite.  He knows his stuff.

=RT=
Logged
ratthing
Journeyman
***
Offline Offline

Posts: 75


View Profile
« Reply #4 on: January 05, 2008, 04:22:26 PM »

So, I spun my wheels and got my mod_rewrites working on my dev server.  Copacetic.  I upload everything to my shared host (cPanel), none of the fscking stuff worked.  I fiddled with rewrite rules until I was cross-eyed, but never got it working.  I can only presume there's some sort of globals in the httpd.conf + the named virtual hosts directives that stomp my rewrite rules.  With no rewrite logging available, it's just guesswork, too.  One more chalk mark in the pro column for VPS.

I ended up putting a check in the header.php for the blog.  A kludge, since I may put up more apps under the domain later, but as BHSEO says, "Just fscking do it!" 80/20 and all that.

I put in a request to my host for my virtual host section of the httpd.conf, we'll see if they give it to me.

=RT=
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!