Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Cookies in index or in new file

    Hellou!

    I want set cookie in index file:

    when i put it in the first line under body it doesnt work!

    I dont know why... it is in first line so there is no output before...

    Could help when i would put the whole page in

    ob_start();

    ob_end_flush();

    I tried it but it still didnt work.

    ?

    Or some ideas?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    When you hit the page that sets cookies, move off of it and check your browser cookies. Does it show them set as there. Also make sure you enable your error reporting:
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    If you get no errors, and your cookie exists, make sure you have the domain and path set properly within the setcookie call. Otherwise we need to see some code.

  • #3
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    When you hit the page that sets cookies, move off of it and check your browser cookies. Does it show them set as there. Also make sure you enable your error reporting:
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    If you get no errors, and your cookie exists, make sure you have the domain and path set properly within the setcookie call. Otherwise we need to see some code.
    i decided to set them in another page but i am curious if something with 'output bufering like' ob_start() or something like that could somehow help because this mean that the whole page with all headers will be send together or not?

  • #4
    Regular Coder Microsuck's Avatar
    Join Date
    Oct 2011
    Location
    127.0.0.1
    Posts
    123
    Thanks
    44
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Trki View Post
    i decided to set them in another page but i am curious if something with 'output bufering like' ob_start() or something like that could somehow help because this mean that the whole page with all headers will be send together or not?
    If your issue is related to the headers already sent error, then yes, output buffering is the answer.
    PHP Code:
    <?php echo "Microsuck says hi!"?>


  •  

    Posting Permissions

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