Results 1 to 2 of 2

Thread: checking for a set cookie

  1. #1

    checking for a set cookie

    Im playing around with cookies for the first time for a website I do.* Its a small time site, mainly for local use.* I want to check and see if a cookie is set when they come to my site, and if it is, display one message, if it isnt, then display a welcome and then set the cookie.* Here is the code I have so far :
    if (isset($_COOKIE['NGBC_Cookie']))
    // User is returning. 
    Print " Welcome back! You last visited us on ";
    echo $_COOKIE["NGBC_Cookie"];
    setcookie("NGBC_Cookie", $now);
    echo $welcome;
    setcookie("NGBC_Cookie", $now);
    I appreciate any help....

    For more info, here is the entire page, which wont run by the way because of this problem...
    $welcome= "Welcome to our Site! Thanks for coming!";
    $now=date("l dS of F Y");
    setcookie("NGBC_Cookie", $now);
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <div align="center">
     <table width="97%" border="5" height="105" bgcolor="#FFFFCC">
       <td height="91"> 
        <div align="center"><img src="../pics/name.gif" width="761" height="74" align="absmiddle"></div></td>
     <table width="97%" border="5" cellspacing="0" cellpadding="0">
      <tr align="center" valign="middle" bgcolor="#FFFFCC"> 
       <td width="77"> <div align="center"><font color="#FFFFFF"><a href="index.php" target="_self">Home</a></font></div></td>
       <td width="119"> <div align="center"><font color="#FFFFFF" size="2"><a href="salvation.php" target="_self">Salvation</a></font></div></td>
       <td width="83"> <div align="center"><font color="#FFFFFF" size="2"><a href="vision.php" target="_self">Our 
       <td width="107"> <div align="center"><font color="#FFFFFF" size="2"><a href="about_us.php" target="_self">About 
       <td width="147"> <div align="center"><font color="#FFFFFF" size="2"><a href="ministries.php" target="_self">Ministries</a></font></div></td>
       <td width="166"> <div align="center"><font color="#FFFFFF" size="2"><a href="missions_community.php" target="_self">Missions 
         &amp; Community</a></font></div></td>
       <td width="148"> <div align="center"><font color="#FFFFFF" size="2"><a href="/calendar/" target="_top">Calendar</a></font></div></td>
       <td width="148"> <div align="center"><font color="#FFFFFF" size="2"><a href="" target="_top">Location 
         &amp; Directions</a></font></div></td>
       <td width="176"> <div align="center"><font color="#FFFFFF" size="2"><a href="prayerlist.php" target="_self">Prayer 
       <td width="11"><font color="#FFFFFF">&nbsp;</font></td>
     <table width="97%" height="42" border="5" cellpadding="0" cellspacing="0">
      <tr bgcolor="#FFFFCC"> 
       <td width="29%" height="32" border="5"> <div align="center"><font color="#0000CC" size="3">Church: 
         (228) 497-2373</font></div>
        <div align="center"><font size="2"><font color="#FFFFFF"><font size="3"></font></font></font></div></td>
       <td height="32" colspan="3" bgcolor="#FFFFCC"> <div align="center"><font color="#0000CC" size="3">Pastor: 
         Bro. Coy Rice</font></div>
        <div align="center"></div></td>
       <td width="36%" height="32" colspan="4"> <div align="center"><font color="#0000CC" size="3">2303 
         Callie Road </font></div></td>
     <table width="97%" border="5" cellpadding="0" cellspacing="0" bgcolor="#FFFFCC">
       <td height="34" align="center"> 
    // <?php
    // Print an individual cookie
    //Print " Welcome back! You last visited us on ";
    //echo $_COOKIE["NGBC_Cookie"];
    if (isset($_COOKIE['NGBC_Cookie']))
    // User is returning. 
    Print " Welcome back! You last visited us on ";
    echo $_COOKIE["NGBC_Cookie"];
    echo $welcome;
    setcookie("NGBC_Cookie", $now);
    //?> </td>

  2. #2
    Senior Member
    Join Date
    Nov 2001

    Re: checking for a set cookie

    You have a line near the bottom that looks like this:

    // ?> </td>

    You need to delete that line and replace it with this:

    should work like a charm after that O0

Similar Threads

  1. Bandwidth Checking
    By pavangogineni in forum Linux - General Topics
    Replies: 9
    Last Post: 04-19-2006, 09:20 AM
  2. Checking if a cookie is set in PHP
    By mountainman in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 01-18-2005, 12:07 PM
  3. Checking stats
    By mcdougrs in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 10-24-2003, 06:21 AM
  4. bandwidth checking
    By in forum General Chat
    Replies: 3
    Last Post: 01-01-2003, 03:16 AM
  5. Replies: 3
    Last Post: 05-13-2002, 05:11 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts