Jump to content

aminnuto

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Posts posted by aminnuto

  1. correction, this code gives me the same result.  works fine when on a page with no other  php code.

     

    <?php
    session_start();
    
    header("Cache-control: private");   // IE6 Fix for Sessions
    
    ob_start();
    ?>
    
    
    <?php
    
    if(isset($_SESSION['box'])) {
    } else {
    include('/home/main/www/inc/box.inc');
    $_SESSION['box'] = "value";
    }
    ?>

     

     

    but when i put it on a page with other php code, it does this.

     

     

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/main/public_html/phppage.php: in /home/main/public_html/phppage.php on line 13
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/main/public_html/phppage.php: in /home/main/public_html/phppage.php on line 15

     

     

     

     

  2. I have an empty php file with this code in it.

     

    <?php
    session_start();
    
    if ($_SESSION['box'])
    {
    } else {
    include('/home/maine/www/inc/box.inc');
    $_SESSION['box'] = "value";
    }
    
    ?>

     

     

    and this page works perfectly.  Its supposed to check for the session cookie and if its not set, show this file, but if it is set, dont show the file.

     

     

    BUT,

    when i insert this code on to the pages through website, they all show this error.

     

     

     

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/main/public_html/page.php: in /home/main/public_html/page.php on line 13
    
    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/main/public_html/page.php.php: in /home/main/public_html/page.php on line 13

     

     

     

     

     

    None of the other pages set a cookie.  So, the code works when its by itself, (on its own blank filename.php page but when I put it on anyother.php file page, i get this error.  Anyone know how to get around this?

     

     

  3. I have a file (in an include file) that I want to put on each webpage on my site.  It loads a javascript hover window.

     

    BUT, I only want it to show up on the first page that a person sees when they come to my site (not necessarily the home page).  Once they see the box, I dont want them to see it again as they navigate to through my site, but i want to make sure they see it at least once when they come to my site so i want to put it on each page.  That way, when a search engine sends them to one page on my site, they see it but wont see it on every page they go to after that.

     

    I need code (i'm guessing a session cookie) that will print my include file if the session has not been set.  Once its been set, do nothing.

     

    Does anyone know how I can do this?

     

     

     

  4. I currently have use this code

    [code]
    <?php
    session_start();

    if ($_SESSION['discount'])
    {
    include('/home/pire/www/products/DISCOUNT-course.php');
    } else {
    include('/home/pire/www/products/REGULAR-course.php');
    $_SESSION['discount'] = "value";
    }

    ?>


    but its only for the session and I want save it for the first 10 visits before it expires (or if thats not possible, expire after 10 days).


    Can anyone help me out with the code to do this?
    [/code]
  5. Does't work. 

    What i'm looking to do is, if someone visits one page on my site they will see a page with the regular price of a product.

    if they go back to that same page within the session, they see different html which will display a discounted price.

    This is the code i'm using.
    [code]<?php
    session_start();

    if ($_SESSION['discount'])
    {
    include('/home/pire/www/products/DISCOUNT-course.php');
    } else {
    include('/home/pire/www/products/REGULAR-course.php');
    $_SESSION['discount'] = "value";
    }

    ?>
    [/code]

    That code is working perfectly.




    BUT, I have a different page on my site which also has the price of that product and I want that page to do the same thing but I DONT want it to set anything (cookie or session). 

    I want that second page to only check and see if the first page has been visited (one or twice doesn’t matter). 

    If that visitor has been to that first page, then i want to display different html

    This is the code i'm using
    [code]<?php
    if (isset($_SESSION['discount'])){
      include('/home/pire/www/products/REGULAR-index.php');
    }
    else {
      include('/home/pire/www/products/DISCOUNT-index.php');
      $_SESSION['discount'] = "value";
    }
    ?>
    [/code]


    This page displays the /home/pire/www/products/DISCOUNT-index.php page wheater they have been to that first page 0 times, 1 time, 2 times 10 times, doesn’t matter.  the /home/pire/www/products/DISCOUNT-index.php page is always shown and I don’t want that. 

    What code would I put on the second page to check if that visitor has been to the first page and if they have, then show them different html?




    By the way...
    Is it possible to make the first code last longer then just the session.  I'd like it to be saved as a cookie and then expire after 10 visits (or if thats not possible, 10 days).
  6. I'm missing something.  I tried your code and it didnt work.

    Here is my original code,
    [code]
    <?php
    session_start();

    if ($_SESSION['discount'])
    {
    include('/home/pire/www/products/DISCOUNT.php');
    } else {
    include('/home/pire/www/products/REGULAR.php');
    $_SESSION['discount'] = "value";
    }

    ?>
    [/code]

    that code works great...


    on the next page, that i want to check for that cookie, i have this
    [code]
    <?php
    if (isset($_COOKIE['discount'])){
    include('/home/pire/www/products/DISCOUNT.php');
    }
    else {
    include('/home/pire/www/products/REGULAR.php');
    $_SESSION['discount'] = "value";
    }
    ?>

    [/code]



    but that doesnt work.  it only displays my REGULAR.php file weather the session is set or not.
  7. ok, one more questions.  I have a different webpage on that site where i want to check and see if this cookie is set and if it is, show one page and if its not, show another BUT i dont want it to set the cookie...only check if its there and then displace an inc file if its there.

    so pretty much the same cookie without setting itself.  just checking if its there and showing an inc file if it is.


    How would I do that?
  8. doesnt work.  i get this error at the top of the page.

    Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/pire/phpfile.php:7) in /home/pire/phpfile.php on line 20

    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/pire/phpfile.php:7) in /home/pire/phpfile.php on line 20





    this is the code i used

    <?php
    session_start();

    if ($_SESSION['name'])
    {
    include('inc/DISCOUNT-file.inc');
    } else {
    include('inc/file.inc');
    $_SESSION['name'] = "value";
    }

    ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.