Jul 24, 2008

Grrrr, Cookies Just Wont Work :(

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Grrrr, Cookies Just Wont Work :(

icedragn
Ok i have tried many tutorials and all tell me to do this:

setcookie("uname", $name, time()+36000);

But it always says:
"Warning: Cannot modify header information - headers already sent"

They say to put it on the very first line with no spaces, which i do, like this:
<?php setcookie("mycookie", $name, time()+36000); ?>

Im using IIS with XP Pro, and have PHP 4.3 installed... why wont it work? sad.gif

**edit, wow i cant believe no one could answer this EASY question, but after reading many documents, i figured out that i hadent declared the $name variable, meanwhile all the gay tutorials didnt happen to MENTION THIS LITTLE FACT.... mad.gif mad.gif , but ne ways, cookies workin great now laugh.gif

 

 

 


Reply

nancmu
Hi!! , icedragn biggrin.gif
I used to get this problem, it's easy to clear....
You might added function to display or html function before you set Cookie code, to solve it.... wink.gif

// do not add any code before this!!!
<?php
ob_start();
echo "................."; // can use "echo" function.
setcookie("uname", $name, time()+36000);
........
echo ".............."; // can use "echo" function.
ob_end_flush();
?>
<html>
<head>
<meta ....>
......
</html>


this's ok!! huh.gif if something wrong........... i'm sorry but i think it's right!!! rolleyes.gif

 

 

 


Reply

Zenchi
QUOTE(icedragn @ Dec 12 2004, 10:36 AM)
**edit, wow i cant believe no one could answer this EASY question, but after reading many documents, i figured out that i hadent declared the $name variable, meanwhile all the gay tutorials didnt happen to MENTION THIS LITTLE FACT.... mad.gif  mad.gif , but ne ways, cookies workin great now  laugh.gif
*



General rule of thumb is to declare any $ variables, beit through and include or whatnot.

Keep this in mind for the future, in case you ever decided to do a script. It can be a hassle and a half.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : grrrr cookies

  1. Blank Cookies... - Need some help with Cookies... (4)
  2. <?php ?> Get Search Results To Your Localhost - Simple way to get 100 results without allowing cookies (2)
    Ultimately simple script that allows you getting google search results to your localhost. This is
    the first part of the Crawler script i'm developing, and if you are interested in developing the
    script with me, IM me @icq328866661@msn/evil_matak/ a \hotmail-com. Here's the form
    part... QUOTE search.php QUOTE if (@$_POST ==""){ echo "What are you
    doing?"; } else{ $query =
    file_get_contents("http://www.google.com/search?q=".urlencode($_POST
    )."&num=100&hl=en&ie=UTF-8&filter=2"); //needs to be added with more queries �...
  3. Using Sessions Instead Of Cookies, Help Please - (1)
    This is a simple code to register and login.. this uses cookies.. i want to use sessions instead..
    can someone tell how i can do it ? config.php CODE <?    ob_start(); // allows you
    to use cookies    $conn =
    mysql_connect("localhost","USER","PASSWORD");   
    mysql_select_db(DATEBASE) or die(mysql_error());    //fill in the above
    lines where there are capital letters.    $logged = MYSQL_QUERY("SELECT * from users
    WHERE id='$_COOKIE[id]' AND password = '$...
  4. Sessions And Login - Without Cookies (5)
    Hi, I have a login script i made using PHP sessions and MySQL. It works fine but there is a
    problem. As you know Sessions are stored in Cookies by PHP. So if someone has switched Cookies off
    then no sessions will work. How to solve this problem ? Please help me. Thanks and have a good
    day. ...
  5. Cookies - How to make something like that? (1)
    Can anybody help me? Im making new website and there will be needed such thing as login... so there
    will be needed thing as cookies too. Can anybody please tell me how to make them and how and where
    to use them? Alredy thanks, Dawiss...



Looking for grrrr, cookies, work

Searching Video's for grrrr, cookies, work
advertisement



Grrrr, Cookies Just Wont Work :(



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE