PHP
Top 100 PHP Interview Questions and Answers
Download PDF 1) What is PHP? PHP is a web language based on scripts that allow developers to...
A cookie is a small file with the maximum size of 4KB that the web server stores on the client computer. Once a cookie has been set, all page requests that follow return the cookie name and value. A cookie can only be read from the domain that it has been issued from. For example, a cookie set using the domain www.guru99.com cannot be read from the domain career.guru99.com. Most of the websites on the internet display elements from other domains such as advertising. The domains serving these elements can also set their own cookies. These are known as third party cookies. A cookie created by a user can only be visible to them. Other users cannot see its value. Most web browsers have options for disabling cookies, third party cookies or both.
A session is a global variable stored on the server. Each session is assigned a unique id which is used to retrieve stored values. Whenever a session is created, a cookie containing the unique session id is stored on the user’s computer and returned with every request to the server. If the client browser does not support cookies, the unique session id is displayed in the URL. Sessions have the capacity to store relatively large data compared to cookies.
The session values are automatically deleted when the browser is closed. If you want to store the values permanently, then you should store them in the database.
Just like the $_COOKIE array variable, session variables are stored in the $_SESSION array variable. Just like cookies, the session must be started before any HTML tags.
Http is a stateless protocol; cookies allow us to track the state of the application using small files stored on the user’s computer. The path were the cookies are stored depends on the browser. Internet Explorer usually stores them in Temporal Internet Files folder. Personalizing the user experience – this is achieved by allowing users to select their preferences. The page requested that follow are personalized based on the set preferences in the cookies. Tracking the pages visited by a user.
To store important information such as the user id more securely on the server where malicious users cannot temper with them. Sessions are used to pass values from one page to another.
It is also used when you want the alternative to cookies on browsers that do not support cookies, to store global variables in an efficient and more secure way compared to passing them in the URL, developing an application such as a shopping cart that has to temporary store information with a capacity larger than 4KB.
|
|
|
|
|
|
|
|
|
|
|
|
Download PDF 1) What is PHP? PHP is a web language based on scripts that allow developers to...
PHP is a server-side scripting language used to develop static and dynamic websites or web...
What is a Function? A function is a reusable piece or block of code that performs a specific...
In this tutorial, you will learn- PHP Data Types PHP Variable Use of variables Variable type...
What is PHP mail? PHP mail is the built in PHP function that is used to send emails from PHP...
Web development is the process of building and maintenance of websites. Web development has a wide...