i already used the code setcookie('variable', $variable, time blabla)
then retrieving it by $_COOKIE('variable')
but it doesnt work.
what am i doing wrong?
i already used the code setcookie('variable', $variable, time blabla)
then retrieving it by $_COOKIE('variable')
but it doesnt work.
what am i doing wrong?
I'ts been a while since I've played with cookies (I normally just use sessions) But as far as I can remember you cannot get the cookie on the same request as you set it.... But I'm not 100% sure though
my site is using sessions right now...
problem is, based from what i researched to know whether a visitor has entered your site before or not is by using cookies...
cookies are used to save the variables on the users computer so they will not have to enter the details again...
anybody know any other way to go around this?
i have been researching around on the net but as of now i havent found anything applicable to my site...
i am using mysql too, if thats any importance...
im not sure what versiion of php coding im using but i think theres a standard so i wont bother with that... hehehe
i just want to grant all the requests that are coming....
Hmm. Well sessions automatically use cookies. So if your session is working, cookies also should work.
Anyhow. What I have done is set the session timeout as a default to 3 months (I think). But you should be able to use cookies if you want to. It's hard to know what's wrong without seeing an example.
And also. Just so you know it.... Opera and Netscape very often have trouble with cookies that IE doesn't have trouble with.
Oh... And a nother thing I thought of... Make sure that the date and time are correct both on your server and on your pc.... I spent two days trying to figure out why a site I made wasn't working with cookies. It turned out that the server date was set to 1998. So IE got cookies that expired in 1998, and just skipped them since they were 5 years outdated.
sorry i dont know
hmmm
maybe your cookie-time is too short?
setcookie ("TestCookie", $value, time()+3600); /* ok for 1 hour */
maybe your IExplorer blocks the cookie?
this is an example...
$cookie_life = time() + 31536000;
$path = '/jesteruk/folder/';
$hostname = 'evolt.org';
setcookie('username', $name, $cookie_life, $path, $hostname);
// Our cookie would be contained in
$HTTP_COOKIE_VARS['username']
// or
$_COOKIE['username']
anything wrong with this code?
setcookie ("TestCookie", $value, time()+3600, "AAAAA", "BBBBB",1);
echo $TestCookie;
echo $HTTP_COOKIE_VARS["TestCookie"];
u have to do a setcookie..then the user will save on on his pc
depending on the domain u use in the cookie..when that user
connects to a page of that domain, the browser will automaticly
send the cookie values to your server
for example if u used setcookie('username', $name, $cookie_life, $path, $hostname);
then..on (every) page u want to recognize the user..use something like this:
echo "welcome back, $username";
and the guy will see his name on the screen![]()
can anyone here help me with some php coding?
i have a mysql database and i want to do a search which allows results to be displayed in a table. From this table i want to have a button which addres information into a shopping cart.
What is the best way to display the results in a table (after the while ($row = mysql_fetch_row ($result)) bit) and have the button:
<a href="cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1">Add Item</a>
is this correct?
im trying to retrieve these cookie code:
<?php
$cookie_life = time() + 31536000;
$hostname = 'franchesca.org';
setcookie('name', $name, $cookie_life, $hostname);
?>
so this is what im doing to retrieve it, and check if its empty or not....
<?php
$_COOKIE['name'];
if ( $name != '' )
?>
Last edited by schizo; 30-03-2003 at 09:08 AM.
to ask a string if "he" is empty i'm useing
if (!$mystring) $mystring = 'ABC';
walter
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks