OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Setting cookie expiration time [duplicate]

  • Thread starter Thread starter Phil
  • Start date Start date
P

Phil

Guest
I'm using this code to generate a cookie named LIDR to save the parameter ?lidr=XXX But Chrome Devtool says that this cookie expire in session :-/

Code:
<script type="text/javascript">
$.urlParam = function(name){
  var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.href);
  if (results==null){
     return null;
  }
  else{
     return results[1] || 0;
  }
}

var source = $.urlParam('lidr').split('&')[0];

// Set the cookies
if(Cookies.get('lidr') == null || Cookies.get('lidr') == "") {
    Cookies.set('lidr', source);
}
</script>

I don't find the way to add a 1 month expiration date. May someone can help me. TIA

Tried several option without success :-/

<p>I'm using this code to generate a cookie named LIDR to save the parameter ?lidr=XXX But Chrome Devtool says that this cookie expire in session :-/</p>
<pre><code><script type="text/javascript">
$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.href);
if (results==null){
return null;
}
else{
return results[1] || 0;
}
}

var source = $.urlParam('lidr').split('&')[0];

// Set the cookies
if(Cookies.get('lidr') == null || Cookies.get('lidr') == "") {
Cookies.set('lidr', source);
}
</script>
</code></pre>
<p>I don't find the way to add a 1 month expiration date. May someone can help me.
TIA</p>
<p>Tried several option without success :-/</p>
 

Latest posts

Top