Saving State with Query Strings in PHP A query string is used to pass small amounts of data between browser requests. Common uses of query strings are: Remembering a user’s entered keywords when using a …
Read More »Preserving State With Query Strings
Building Query Strings in PHP
Building Query Strings in PHP Query strings are not limited to form data. Query string is simply a string of characters stored in a URL, a user can manually create a URL containing a query …
Read More »Accessing Data in Query Strings in PHP
Accessing Data in Query Strings in PHP To access the field names and values in a query string you simply use the $_GET superglobal array function. Syntax $firstName = $_GET[“firstName”]; Example Here, we will illustrate an example …
Read More »Working with Cookies in PHP
Working with Cookies in PHP Cookies allow users to store a small amount of data, not more than 4KB within the user’s browser itself. Then, whenever the browser requests a page on the Web site, …
Read More »Cookie Components in PHP
Cookie Components in PHP A cookie is sent from the server to the browser as part of the HTTP headers. Here we will illustrate an example of an HTTP header to create a cookie: Set-Cookie: …
Read More »Setting a Cookie in PHP
Setting a Cookie in PHP PHP provides a built – in function, setcookie() , that can send the appropriate HTTP header to create the cookie on the browser. Here, you will learn how to set …
Read More »Accessing Cookies Scripts In PHP
Accessing Cookies Scripts In PHP To Access cookies in PHP is very easy: A user can simply read values from the $_COOKIE superglobal array. To display the pageViews cookie set use : echo $_COOKIE[“pageViews”]; // …
Read More »Removing Cookies In PHP
Removing Cookies In PHP If a user no longer needs a cookie that is stored on the user’s browser, then a user can instruct the browser to delete it. To delete a cookie, a user …
Read More »Working with Sessions in PHP
Although cookies are a useful way to store data but they have some problems like Firstly, they are not very secure. As with form data and query strings, an attacker can easily modify a cookie’s …
Read More »Creating a PHP Session
PHP Session new session, this function generates a unique SID for the session and sends it to the browser as a cookie called PHPSESSID (by default). However, if the browser has sent a PHPSESSID cookie …
Read More »Reading and Writing Session Data in PHP
Working with session data in PHP is also simple. A user can store all the session data as keys and values in the $_SESSION[] superglobal array. So a user might store the user’s first name …
Read More »Destroying a Session
As earlier you have read that by default PHP sessions are automatically deleted when users quit their browser, because the PHPSESSID cookie ’ s expires field is set to zero. However, sometimes a user might …
Read More »