Which is the most reliable method to setup a cookie: Javascript Or php?

I'm using this javascript function to setup a cookie on my site that will show a div wile the cookie isn't setup.

function accept_cookies(){     days=365; // number of days to keep the cookie     myDate = new Date();     myDate.setTime(myDate.getTime()+(days*24*60*60*1000));     document.cookie = 'cookie_t=1; expires=' + myDate.toGMTString(); } 


<a onClick="HideContent('cookies'); accept_cookies()" href="javascript:HideContent('cookies')">     ok </a> 

This method works great on my desktop device but, on my android phone it doesn't work so well. I know this because I click the link several times and the div keeps on showing after it the link saying that is ok.


You can use the php method "setcookie" to create a Set-Cookie header, that will set a cookie on the client side.


Processes that happens in the server side (php) are much more reliable than on the client side.

Category: php Time: 2016-07-30 Views: 10

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.140 (s). 12 q(s)