MOST IMPORTANT QUESTIONS GENERALLY USED TO BE ASKED IN THE INTERVIEW ON SESSION AND COOKIES OF PHP
MOST IMPORTANT QUESTIONS GENERALLY USED TO BE ASKED IN THE INTERVIEW ON SESSION AND COOKIES OF PHP
Q1. What is the difference between GET() and POST() method?
Ans: GET() Method = > GET() Method is the less secure method. GET() Method can pass the query string.
POST() Method => POST() Method is the most secure method. POST() Method cannot pass the query string.
Q2. Explain the function of cookies?
Ans: The function of cookies is to hold the data of the users.
Q3. What do you mean by Cookie?
Ans: Cookie is a small file sent by the server to the client machine to trace how long ago the user has visited the website. Cookie is used to store the user information on the client machine. Cookie in PHP has a super global variable $_COOKIE. Real Life Example => Remember Me.
Q4. Why Cookie is known as Global Carrier of data?
Ans: Scope of Cookie is set to application layer. If we create Cookie in one page, we can reuse it's value to all other pages of the same application. That is why Cookie is known as Global Carrier of data.
Q5. Which function is used to create and destroy cookie?
Ans: setcookie() function is used to create and destroy cookie.
Q6. What do you mean by Session?
Ans: Session is also known as Global Carrier of data like Cookies. It is used to store user activity on website. It's used to store user information on the server.
Q7. Why session is known as Global Carrier of data?
Ans: Scope of session is also set to Application Layer like Cookies. If we create session in one page, we can reuse it's value to all other pages of the same application. That is why Session is known as Global Carrier of data.
Q8. What is the super global variable used to generate and retrieve session values?
Ans: The super global variable is $_SESSION to generate and retrieve session values.
Q9. What are the two mechanisms to delete session?
Ans: The two mechanisms to delete sessions are as follows:
1) unset(SessionId) = Deleting a particular session.
2) session_destroy() = Delete all sessions.
Q10. What is the difference between Cookie and Session?
Ans: Cookie => Cookie is used to store user information on the client machine through web browser. Cookie can have 0-2048 bytes of data to store user information. Cookie is less secure. Real Life Example : Remember Me.
Session => Session is used to store user information on the server. Session does not have any limit. Session is more secure. Real Life Examples : login, logout, multistep form.
Comments
Post a Comment