[Skip to main content](#vessel-content)

#   Clear Cookies

##

- **[bars92](/forum/user/3048-bars92 "View bars92's Profile")**
- [![bars92's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/3048-bars92 "View bars92's Profile") Topic Author
- [ Offline](/forum/user/3048-bars92)

Less More

- Posts: 108
- Thank you received: 2
-
-

15 years 2 months ago [\#24342](#24342) by [bars92](/forum/user/3048-bars92 "View bars92's Profile")  *[Clear Cookies](/forum/4-how-to/24342-clear-cookies#24342 "Hello again.  I am trying to make a button to clear all cookies (partner&#95;id primery). i used this code in a blank module (PHP enabled):  function deleteCookies() { if (isset($&#95;SERVER)) { $cookies = explode(';', $&#95;SERVER); foreach($cookies as $cookie) {  $parts = explode('=', $cookie); $name = trim($parts&#91;0&#93;); setcookie($name, '', time()-1000); setcookie($name, '', time()-1000, '/'); } } echo ''; echo 'alert(&quot;Cookies Deleted!&quot;)'; echo '';  }  echo '';  but when i am runing it, it does not clear the most importent cookie, the partner&#95;id.. So i am asking, can something close to this can be done to clear the partner&#95;id cookie?  thanks alot.")* was created by *[bars92](/forum/user/3048-bars92 "View bars92's Profile")*

Hello again.

I am trying to make a button to clear all cookies (partner_id primery).
i used this code in a blank module (PHP enabled):

function deleteCookies()
{
if (isset($_SERVER)) {
$cookies = explode(';', $_SERVER);
foreach($cookies as $cookie) {

$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', time()-1000);
setcookie($name, '', time()-1000, '/');
}
}
echo '&lt;script type="text/javascript"&gt;';
echo 'alert("Cookies Deleted!")';
echo '&lt;/script&gt;';

}

echo '&lt;input type="button" onClick="'.deleteCookies().'" value="Clear Cookie" /&gt;&lt;br&gt;';

but when i am runing it, it does not clear the most importent cookie, the partner_id..
So i am asking, can something close to this can be done to clear the partner_id cookie?

thanks alot.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI0MzQyLWNsZWFyLWNvb2tpZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14276
-
-

15 years 2 months ago [\#24350](#24350) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Clear Cookies](/forum/4-how-to/24342-clear-cookies#24350 "Hello again.  I am trying to make a button to clear all cookies (partner&#95;id primery). i used this code in a blank module (PHP enabled):  function deleteCookies() { if (isset($&#95;SERVER)) { $cookies = explode(';', $&#95;SERVER); foreach($cookies as $cookie) {  $parts = explode('=', $cookie); $name = trim($parts&#91;0&#93;); setcookie($name, '', time()-1000); setcookie($name, '', time()-1000, '/'); } } echo ''; echo 'alert(&quot;Cookies Deleted!&quot;)'; echo '';  }  echo '';  but when i am runing it, it does not clear the most importent cookie, the partner&#95;id.. So i am asking, can something close to this can be done to clear the partner&#95;id cookie?  thanks alot.")*

You should use $_COOKIE directly in your foreach. But I don't think that it comes from that.
You code seems correct.

Maybe it's because you have partner_id somewhere which is set again automatically at some point after you delete it ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI0MzQyLWNsZWFyLWNvb2tpZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[bars92](/forum/user/3048-bars92 "View bars92's Profile")**
- [![bars92's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/3048-bars92 "View bars92's Profile") Topic Author
- [ Offline](/forum/user/3048-bars92)

Less More

- Posts: 108
- Thank you received: 2
-
-

15 years 2 months ago [\#24353](#24353) by [bars92](/forum/user/3048-bars92 "View bars92's Profile")  Replied by *[bars92](/forum/user/3048-bars92 "View bars92's Profile")* on topic *[Re: Clear Cookies](/forum/4-how-to/24342-clear-cookies#24353 "Hello again.  I am trying to make a button to clear all cookies (partner&#95;id primery). i used this code in a blank module (PHP enabled):  function deleteCookies() { if (isset($&#95;SERVER)) { $cookies = explode(';', $&#95;SERVER); foreach($cookies as $cookie) {  $parts = explode('=', $cookie); $name = trim($parts&#91;0&#93;); setcookie($name, '', time()-1000); setcookie($name, '', time()-1000, '/'); } } echo ''; echo 'alert(&quot;Cookies Deleted!&quot;)'; echo '';  }  echo '';  but when i am runing it, it does not clear the most importent cookie, the partner&#95;id.. So i am asking, can something close to this can be done to clear the partner&#95;id cookie?  thanks alot.")*

thanks for replay.
I checked again and both $_COOKIE and $_SERVER contains only the basic joomla cookies.. not login info,hikashop, languague or anything else (__utma,__utmb...), i guess because this is external page without joomla authentication.. (blank module display the same cookies with $_SERVER).

I elso cannot use $_COOKIE at the blank module because i cannot start session in there..

Any ideas?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI0MzQyLWNsZWFyLWNvb2tpZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14276
-
-

15 years 2 months ago [\#24356](#24356) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Clear Cookies](/forum/4-how-to/24342-clear-cookies#24356 "Hello again.  I am trying to make a button to clear all cookies (partner&#95;id primery). i used this code in a blank module (PHP enabled):  function deleteCookies() { if (isset($&#95;SERVER)) { $cookies = explode(';', $&#95;SERVER); foreach($cookies as $cookie) {  $parts = explode('=', $cookie); $name = trim($parts&#91;0&#93;); setcookie($name, '', time()-1000); setcookie($name, '', time()-1000, '/'); } } echo ''; echo 'alert(&quot;Cookies Deleted!&quot;)'; echo '';  }  echo '';  but when i am runing it, it does not clear the most importent cookie, the partner&#95;id.. So i am asking, can something close to this can be done to clear the partner&#95;id cookie?  thanks alot.")*

Oh, I didn't saw the last line of code, but I can see that you're trying to call a php function with javascript. That's not possible. What you code does is that it calls the deleteCookies function on every page where you have the code and displays the alert box, regardless of whether you click on the button or not.
You would have to create a form and have a controller or at leadt a php page which would be called by the button where you would have your code.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI0MzQyLWNsZWFyLWNvb2tpZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[bars92](/forum/user/3048-bars92 "View bars92's Profile")**
- [![bars92's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/3048-bars92 "View bars92's Profile") Topic Author
- [ Offline](/forum/user/3048-bars92)

Less More

- Posts: 108
- Thank you received: 2
-
-

15 years 2 months ago [\#24360](#24360) by [bars92](/forum/user/3048-bars92 "View bars92's Profile")  Replied by *[bars92](/forum/user/3048-bars92 "View bars92's Profile")* on topic *[Re: Clear Cookies](/forum/4-how-to/24342-clear-cookies#24360 "Hello again.  I am trying to make a button to clear all cookies (partner&#95;id primery). i used this code in a blank module (PHP enabled):  function deleteCookies() { if (isset($&#95;SERVER)) { $cookies = explode(';', $&#95;SERVER); foreach($cookies as $cookie) {  $parts = explode('=', $cookie); $name = trim($parts&#91;0&#93;); setcookie($name, '', time()-1000); setcookie($name, '', time()-1000, '/'); } } echo ''; echo 'alert(&quot;Cookies Deleted!&quot;)'; echo '';  }  echo '';  but when i am runing it, it does not clear the most importent cookie, the partner&#95;id.. So i am asking, can something close to this can be done to clear the partner&#95;id cookie?  thanks alot.")*

Ok now i know why that happened.. thanks ![:)](/media/kunena/emoticons/3.png ":)")

I cant use form because i need link that will do the clearing (unvisible link), although i changed to form to see and it is working, but still the cookies that are being cleaned are the basics, and not hikashop_affiliate..

I got no ideas what to do, so i can see all of my website cookies...

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI0MzQyLWNsZWFyLWNvb2tpZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14276
-
-

15 years 2 months ago [\#24363](#24363) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Clear Cookies](/forum/4-how-to/24342-clear-cookies#24363 "Hello again.  I am trying to make a button to clear all cookies (partner&#95;id primery). i used this code in a blank module (PHP enabled):  function deleteCookies() { if (isset($&#95;SERVER)) { $cookies = explode(';', $&#95;SERVER); foreach($cookies as $cookie) {  $parts = explode('=', $cookie); $name = trim($parts&#91;0&#93;); setcookie($name, '', time()-1000); setcookie($name, '', time()-1000, '/'); } } echo ''; echo 'alert(&quot;Cookies Deleted!&quot;)'; echo '';  }  echo '';  but when i am runing it, it does not clear the most importent cookie, the partner&#95;id.. So i am asking, can something close to this can be done to clear the partner&#95;id cookie?  thanks alot.")*

You should create a component/controller/task, or a plugin or a module in joomla in order to have the session activated for your code then.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI0MzQyLWNsZWFyLWNvb2tpZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.067 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
