Jump to content

$_COOKIE question


dhimok

Recommended Posts

Hello everyone. I have this question

 

Is it possible to control cookies from my own domain stored on users computers? I wonder if I can change the expiry date, increase or decrease or delete them, while they are already set from before

 

Thanks

Link to comment
Share on other sites

I would like to add some more details:

 

Lets say I store a cookie when a user enters my page that will expire in 1 year. Next time the same user enters the page it wont set the cookie again, unless its not there. Now I want that cookie which is stored to expire in 3 days. Is this possible and if yes then how

Link to comment
Share on other sites

This is what I did. I think its ok

 


if(!isset($_COOKIE["uid"])) {
$uid =  sha1(session_id().@time()); 
$expire1 = 365*24*3600; // 1 year
setcookie("uid", $uid, (time() + $expire)); 
} else {
$expire2 = 7*24*3600; // 1 week;
setcookie("uid", $_COOKIE["uid"], (time() + $expire2)); 
}

 

Any other ideas would be appriciated

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.