snipt

Ctrl+h for KB shortcuts

PHP

Show different Div's based on cookies

1
2
3
4
5
6
7
8
<?php
if(isset($_COOKIE['div'])){
echo "<div>I can tell you've been here before</div>";
} else {
setcookie('div', true, 5184000 + time()); //hold fo 2 months
echo "<div>Its your first time being here</div>";
}
?> 
https://snipt.net/embed/3bbc08bdb01073b739fbb3e4b0d59721/
https://snipt.net/raw/3bbc08bdb01073b739fbb3e4b0d59721/
3bbc08bdb01073b739fbb3e4b0d59721
php
PHP
8
2016-09-26T13:44:20
True
False
False
Jul 02, 2014 at 07:26 PM
/api/public/snipt/48009/
show-different-divs-based-on-cookies
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="k">if</span><span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$_COOKIE</span><span class="p">[</span><span class="s1">&#39;div&#39;</span><span class="p">])){</span> </span><span id="L-3"><a name="L-3"></a><span class="k">echo</span> <span class="s2">&quot;&lt;div&gt;I can tell you&#39;ve been here before&lt;/div&gt;&quot;</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> <span class="k">else</span> <span class="p">{</span> </span><span id="L-5"><a name="L-5"></a><span class="nb">setcookie</span><span class="p">(</span><span class="s1">&#39;div&#39;</span><span class="p">,</span> <span class="k">true</span><span class="p">,</span> <span class="mi">5184000</span> <span class="o">+</span> <span class="nb">time</span><span class="p">());</span> <span class="c1">//hold fo 2 months</span> </span><span id="L-6"><a name="L-6"></a><span class="k">echo</span> <span class="s2">&quot;&lt;div&gt;Its your first time being here&lt;/div&gt;&quot;</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a><span class="p">}</span> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"> </span> </span></pre></div> </td></tr></table>
cookies, php

JavaScript

Cookie management

1
2
3
4
5
function setCookie(n, v, d, e){var de = new Date;de.setTime(de.getTime() + e*24*60*60*1000);document.cookie = n +
"=" + escape(v) + ((e==null) ? "" : ("; expires=" + de.toGMTString())) + "; path=/" + ((d==null) ? "" : (";domain=" + d));}
function getDomain(){var sld = document.domain;var dp = sld.split(".");var l = dp.length;if (l < 2)
sld = null;else if (!isNaN(dp[l-1]) && !isNaN(dp[l-2])) sld = null;else sld = "." + dp[l-2] + "." + dp[l-1];return sld;}
function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; }
https://snipt.net/embed/c5e08517dba94685fc3437c6542e87ff/
https://snipt.net/raw/c5e08517dba94685fc3437c6542e87ff/
c5e08517dba94685fc3437c6542e87ff
js
JavaScript
5
2016-09-26T19:09:03
True
False
False
/api/public/snipt/38802/
cookie-management
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="kd">function</span> <span class="nx">setCookie</span><span class="p">(</span><span class="nx">n</span><span class="p">,</span> <span class="nx">v</span><span class="p">,</span> <span class="nx">d</span><span class="p">,</span> <span class="nx">e</span><span class="p">){</span><span class="kd">var</span> <span class="nx">de</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">;</span><span class="nx">de</span><span class="p">.</span><span class="nx">setTime</span><span class="p">(</span><span class="nx">de</span><span class="p">.</span><span class="nx">getTime</span><span class="p">()</span> <span class="o">+</span> <span class="nx">e</span><span class="o">*</span><span class="mi">24</span><span class="o">*</span><span class="mi">60</span><span class="o">*</span><span class="mi">60</span><span class="o">*</span><span class="mi">1000</span><span class="p">);</span><span class="nb">document</span><span class="p">.</span><span class="nx">cookie</span> <span class="o">=</span> <span class="nx">n</span> <span class="o">+</span> </span><span id="L-2"><a name="L-2"></a><span class="s2">&quot;=&quot;</span> <span class="o">+</span> <span class="nx">escape</span><span class="p">(</span><span class="nx">v</span><span class="p">)</span> <span class="o">+</span> <span class="p">((</span><span class="nx">e</span><span class="o">==</span><span class="kc">null</span><span class="p">)</span> <span class="o">?</span> <span class="s2">&quot;&quot;</span> <span class="o">:</span> <span class="p">(</span><span class="s2">&quot;; expires=&quot;</span> <span class="o">+</span> <span class="nx">de</span><span class="p">.</span><span class="nx">toGMTString</span><span class="p">()))</span> <span class="o">+</span> <span class="s2">&quot;; path=/&quot;</span> <span class="o">+</span> <span class="p">((</span><span class="nx">d</span><span class="o">==</span><span class="kc">null</span><span class="p">)</span> <span class="o">?</span> <span class="s2">&quot;&quot;</span> <span class="o">:</span> <span class="p">(</span><span class="s2">&quot;;domain=&quot;</span> <span class="o">+</span> <span class="nx">d</span><span class="p">));}</span> </span><span id="L-3"><a name="L-3"></a><span class="kd">function</span> <span class="nx">getDomain</span><span class="p">(){</span><span class="kd">var</span> <span class="nx">sld</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">domain</span><span class="p">;</span><span class="kd">var</span> <span class="nx">dp</span> <span class="o">=</span> <span class="nx">sld</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s2">&quot;.&quot;</span><span class="p">);</span><span class="kd">var</span> <span class="nx">l</span> <span class="o">=</span> <span class="nx">dp</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="k">if</span> <span class="p">(</span><span class="nx">l</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a><span class="nx">sld</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span><span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">dp</span><span class="p">[</span><span class="nx">l</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">dp</span><span class="p">[</span><span class="nx">l</span><span class="o">-</span><span class="mi">2</span><span class="p">]))</span> <span class="nx">sld</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span><span class="k">else</span> <span class="nx">sld</span> <span class="o">=</span> <span class="s2">&quot;.&quot;</span> <span class="o">+</span> <span class="nx">dp</span><span class="p">[</span><span class="nx">l</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;.&quot;</span> <span class="o">+</span> <span class="nx">dp</span><span class="p">[</span><span class="nx">l</span><span class="o">-</span><span class="mi">1</span><span class="p">];</span><span class="k">return</span> <span class="nx">sld</span><span class="p">;}</span> </span><span id="L-5"><a name="L-5"></a><span class="kd">function</span> <span class="nx">getCookie</span><span class="p">(</span><span class="nx">c_name</span><span class="p">)</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">cookie</span><span class="p">.</span><span class="nx">length</span><span class="o">&gt;</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="nx">c_start</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">cookie</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">c_name</span> <span class="o">+</span> <span class="s2">&quot;=&quot;</span><span class="p">);</span> <span class="k">if</span> <span class="p">(</span><span class="nx">c_start</span><span class="o">!=-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span> <span class="nx">c_start</span><span class="o">=</span><span class="nx">c_start</span> <span class="o">+</span> <span class="nx">c_name</span><span class="p">.</span><span class="nx">length</span><span class="o">+</span><span class="mi">1</span><span class="p">;</span> <span class="nx">c_end</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">cookie</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;;&quot;</span><span class="p">,</span><span class="nx">c_start</span><span class="p">);</span> <span class="k">if</span> <span class="p">(</span><span class="nx">c_end</span><span class="o">==-</span><span class="mi">1</span><span class="p">)</span> <span class="nx">c_end</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">cookie</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="k">return</span> <span class="nx">unescape</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">cookie</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="nx">c_start</span><span class="p">,</span><span class="nx">c_end</span><span class="p">));</span> <span class="p">}</span> <span class="p">}</span> <span class="k">return</span> <span class="s2">&quot;&quot;</span><span class="p">;</span> <span class="p">}</span> </span></pre></div> </td></tr></table>
cookies

Text only

phpMyAdmin Cookies

1
2
3
4
5
6
7
 If you are continuing to have issues logging in to phpMyAdmin then I generally suggest deleting any cookies in your browser that have come from gridserver.com. For more information on how to remove cookies from your specific browser, please review the link posted below. 

http://www.aboutcookies.org/Default.aspx?page=2

For how to access phpMyAdmin on your (gs) Grid-Service please see our KnowledgeBase article at http://kb.mediatemple.net/questions/1570/.

I hope this helped you out and I'll definitely answer any other questions you may have. Just let us know!
https://snipt.net/embed/dbccf19c4a0c602e3cae25a107be0870/
https://snipt.net/raw/dbccf19c4a0c602e3cae25a107be0870/
dbccf19c4a0c602e3cae25a107be0870
text
Text only
7
2016-09-22T15:16:29
True
False
False
/api/public/snipt/11458/
phpmyadmin-cookies
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a> If you are continuing to have issues logging in to phpMyAdmin then I generally suggest deleting any cookies in your browser that have come from gridserver.com. For more information on how to remove cookies from your specific browser, please review the link posted below. </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>http://www.aboutcookies.org/Default.aspx?page=2 </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>For how to access phpMyAdmin on your (gs) Grid-Service please see our KnowledgeBase article at http://kb.mediatemple.net/questions/1570/. </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a>I hope this helped you out and I&#39;ll definitely answer any other questions you may have. Just let us know! </span></pre></div> </td></tr></table>
cookies, phpmyadmin
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.