Jump to content

Archived

This topic is now archived and is closed to further replies.

[)OBER]V[AN

Problem With Cookies

Recommended Posts

hi all, can anyone help me?
[code]setcookie('user_id',1,mktime(0, 0, 0, 12, 32, 2030)); [/code]

when i try to display the valeu of $_COOKIE['user_id']
in IE it works,
in Opera it doesn't

In Opera it some how disappears [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /]

Share this post


Link to post
Share on other sites
have you tried changing the ammount of time it's set by?
for example set it in seconds??

Try the tutorials to find out how...
Then again i never use opera.

Share this post


Link to post
Share on other sites
the strange thing when i try to display in in IE:
Array
(
[user_id] => 1
)
it works.....

but Opera:
Array
(
)

cookie is gone :(

Share this post


Link to post
Share on other sites
Browser settings is ok, it accepts cookies.
In opera it creats the cookie and it working wile the page is up, when i close opera and try to open it again the cookie is gone...
[img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /]

Share this post


Link to post
Share on other sites
Make sure you dont have the setting "[i]Delete new cookies when exiting Opera[/i]" is ticked. You can check this by going to Tools -> Preferences Avanced Tab -> Cookies

Thats the only thing I ahve come up as to why Opera is deleting the cookie.

Share this post


Link to post
Share on other sites
Intresting! I have tried your script and it works fine for me. I have no idea what else might be the problem. This is the code I used:
[code]<?php

// check that cookie hasnt been set
if(!isset($_COOKIE['user_id']))
{
    // set the cookie
    setcookie('user_id',1,mktime(0, 0, 0, 12, 32, 2030));

    echo "Cookie has been set. Refresh the browser window";
}
else
{
    // get the cookie
    echo "Retrieving cookie...<br />\n";
    echo $_COOKIE['user_id'];
}

?>[/code]

Share this post


Link to post
Share on other sites
wildteen88 make one page with this code:
[code]
<?php

// check that cookie hasnt been set
if(!isset($_COOKIE['user_id']))
{
    // set the cookie
    setcookie('user_id',1,mktime(0, 0, 0, 12, 32, 2030));

    echo "Cookie has been set. Refresh the browser window";
}
?>
[/code]
and enother page with this code:
[code]
<?php

// check that cookie hasnt been set
if(isset($_COOKIE['user_id']))
{
    // get the cookie
    echo "Retrieving cookie...<br />\n";
    echo $_COOKIE['user_id'];
}
?>
[/code]

do the folowing:
1) activate the first page.
2) go to the second page.
3) close the opera.
4) open the opera and open the second page ""WITHOUT THE FIRST ONE""!!!
5) do refresh and you will see that the cookie is not set any more

Share this post


Link to post
Share on other sites
Did what you said and it works fine for me. Cookie is still set.

EDIT: Heres a [url=http://homepage.ntlworld.com/cshepwood/cookie_opera2.wmv]short video[/url]

Share this post


Link to post
Share on other sites
I found the problem....
Opera doesn't save cookies from local files, when i uploaded the files to a host, the cookie worked...
:-\  i wish it would work on local files too

Share this post


Link to post
Share on other sites
It does work with local files. Look at the attached video, you'll see the files are being served locally.

Share this post


Link to post
Share on other sites

×

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.