Hi Monks,

I'm writing a little script to read a phpbb cookie from pages outside the forum. If the person is logged in, I print one thing, if they're not logged in I print another.

This worked when I only ran it on one site, but now it's getting confused. I have several domains running the same kind of forums, and I'm running this script on each domain. All of a sudden the script doesn't know whether it's logged in or not. It's as if it is reading a cookie from another domain. Is that possible? Shouldn't this code tell it to read the cookie on the domain it's called from?

local(@getcookies) = split (/; /,$ENV{'HTTP_COOKIE'}); local(%cookies); foreach(@getcookies){ ($ckey, $cval) = split (/=/,$_); $cookies{$ckey} = $cval; } $user_logged = $cookies{'phpbb2mysql_data'}; $user_sid = $cookies{'phpbb2mysql_sid'}; if ($user_logged !~ /autologinid/) { print <<HTML; <a NOCOLOR NOUNDERLINE id="top3" href="/forums/login.php?" target=_top +><SPAN STYLE="COLOR: #0033cc">Log in</span></a> &nbsp; HTML } else { print <<HTML; <SPAN STYLE="COLOR: #0033cc" id="top3" >Welcome back! | <a NOCOLOR NOU +NDERLINE id="top3" href="/forums/login.php?logout=true&sid=$user_sid" + target=_top>Log out</a></span> &nbsp; HTML }

In reply to Help reading cookies by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.