Topic 4 Session (1)jAhdgksjdhsjskshsjsksj.pptx

sanchaniyariya 10 views 13 slides Oct 17, 2024
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13

About This Presentation

Bunch


Slide Content

Chapter:-3 Topic:-session

Topic to be covered About sessoin ,how to start use and destroy session

What is session ? $_SESSION is a special array used to store information across the pages and are available to all pages in one application. When you are working with an application, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end.

What is session ? But on the internet there is one problem: the web server does not know who you are and what you do because the HTTP address doesn't maintain state. A PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping items, etc).

What is session ? Sessions work by creating a unique id (UID) for each visitor and store variables based on this UID. The UID is either stored in a cookie or is propagated in the URL. However, session information is temporary and will be deleted after the user has left the website. If you need a permanent storage you may want to store the data in a database

cookies Cookie is store on client machine . Cookies can be disabled or edited by the visitor. So it is not used for store sensitive data. which are relatively small compare to session Common uses for cookies is for authentication If you don't need permanent data, cookies are use.

session session is store on server. Sessions cannot be disabled or edited by the visitor.   they can be as large as needed, in comparison with cookies A PHP session allowing you to store user information on the server for later use If you don't need any permanent data, sessions are easy to use.

How to start session? Before you can store user information in your PHP session, you must first start up the session. <?php session_start(); ?> <html> <body></body></html>

Storting a session variable <?php session_start(); $_SESSION['user']="admin"; ?> <html><body> <?php echo "UserName=". $_SESSION['user']; ?> </body></html>

Destroying a session variable If you wish to delete some session data, you can use the unset() or the session_destroy() function. <?php session_start(); if(isset($_SESSION[‘user'])) unset($_SESSION[‘user']); ?>

Assignment question for 1 marks 1. session are stored on ______________. 2. session can be started using _________ function. 3. session can be deleted using _________ function. 4. session data are stored in server temp file true/false. 5. define term session. 6. client can disable session true/false. 7.session can be destroy using _________ and _________ function.

Assignment question for 5 marks 1. write a note on session. 2. give difference between session/cookies. 3. explain with example how to start and store session. 4. explain with example how to delete (destroy) session. 5. explain any 3 function which can be used for session. Note:- combine of any 2 question of 5 marks can be asked as 7 marks

Thank you
Tags