Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Text only

Create a new MySQL user and grant permissions

1
2
3
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
FLUSH PRIVILEGES;
https://snipt.net/embed/e75d2b07cd56ee71c09da2af27eb7b58/
https://snipt.net/raw/e75d2b07cd56ee71c09da2af27eb7b58/
e75d2b07cd56ee71c09da2af27eb7b58
text
Text only
3
2016-12-10T07:42:22
True
False
False
Jan 20, 2014 at 07:43 AM
/api/public/snipt/107183/
create-a-new-mysql-user-and-grant-permissions
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>CREATE USER &#39;newuser&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;password&#39;; </span><span id="L-2"><a name="L-2"></a>GRANT ALL PRIVILEGES ON *.* TO &#39;newuser&#39;@&#39;localhost&#39;; </span><span id="L-3"><a name="L-3"></a>FLUSH PRIVILEGES; </span></pre></div> </td></tr></table>
mysql, user

Text only

Check if logged in

1
2
3
4
5
6
7
$user = JFactory::getUser();
if($user->id){
      // do something because user is logged in
}
esle{
      // do something because user is not logged in
}
https://snipt.net/embed/36ab338cb18ebbd002ec051fca5afe19/
https://snipt.net/raw/36ab338cb18ebbd002ec051fca5afe19/
36ab338cb18ebbd002ec051fca5afe19
text
Text only
7
2016-12-08T10:14:03
True
False
False
Dec 03, 2013 at 06:10 AM
/api/public/snipt/98156/
check-if-logged-in
<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></span><span id="L-1"><a name="L-1"></a>$user = JFactory::getUser(); </span><span id="L-2"><a name="L-2"></a>if($user-&gt;id){ </span><span id="L-3"><a name="L-3"></a> // do something because user is logged in </span><span id="L-4"><a name="L-4"></a>} </span><span id="L-5"><a name="L-5"></a>esle{ </span><span id="L-6"><a name="L-6"></a> // do something because user is not logged in </span><span id="L-7"><a name="L-7"></a>} </span></pre></div> </td></tr></table>
joomla, login, user
Copyrighted, illegal, or inappropriate content? Email [email protected].