title: What exactly does happen by means or URL encoding and URL decoding while dealing with cookies in PHP?
body: <p>I'm learning the concept of <strong>Cookies</strong> in PHP from <a href="https://www.w3schools.com/php/php_cookies.asp" rel="nofollow noreferrer">this link</a></p>
  
  <p>Till now I've understood that </p>
  
  <p><strong>A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.</strong></p>
  
  <p>I studied the following demo program present at the above link location :</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;?php
    $cookie_name = "user";
    $cookie_value = "John Doe";
    setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
  ?&gt;
  &lt;html&gt;
    &lt;body&gt;
  
    &lt;?php
      if(!isset($_COOKIE[$cookie_name])) {
        echo "Cookie named '" . $cookie_name . "' is not set!";
      } else {
        echo "Cookie '" . $cookie_name . "' is set!&lt;br&gt;";
        echo "Value is: " . $_COOKIE[$cookie_name];
      }
    ?&gt;
  
    &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You might have to reload the page to see the value of the cookie.&lt;/p&gt;
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>After going through the above code few questions have raised in my mind. I want satisfactory answers for them.</p>
  
  <ol>
  <li>As cookie is nothing but a file that server embeds on the user's computer then where is the file creation and manipulation code? Without file manipulation and file uploading code how does the server embed file on user's computer or how does the browser send request to the server along with the cookie file?</li>
  <li>Although, if I believe that the cookie file has been embedded by the server on user's computer then where is the file located on my machine that runs on Windows 10 Home Edition?</li>
  </ol>
  
  <p>I also read one statement as below :</p>
  
  <p><strong>Note:</strong> The value of the cookie is automatically URLencoded when sending the cookie, and automatically decoded when received (to prevent URLencoding, use setrawcookie() instead).</p>
  
  <p>Let me frankly tell you I didn't get at all what this sentence mean and what exactly does happen while sending and receiving cookies. I also don't know what is URL encoding and URL decoding in PHP? </p>
  
  <p>It would be better if someone clears all of my above doubts with good explanatory answer and working code example.</p>
  
  <p>Let me tell you honestly that as I heard from experienced PHP developers that Cookies and Session are the most important, basic concepts in PHP. But, I'm finding them difficult to understand. So, please explain me in simple and lucid language that I could grasp these concepts in a better and easier manner.</p>
  
  <p>In short I want to understand the concept, functioning and usage of cookies in PHP with the working code example.</p>
  
  <p>Thank You.</p>