Sei sulla pagina 1di 8

Session

Assignment prepared By CHAT_Noze

Course : CERTIFICATE IN ADVANCE WEB DEVELOPMENT November, 2011

Orient Academy Limited (An LOLC Group company)

Contents

(01) (02) (03) (04) (05)

General meaning of session Introduction of session Analysis Findings List of references

General meaning of session


(01) a. A meeting of a legislative or judicial body for the purpose of transacting business. b. A series of such meetings. c. The term or duration of time that is taken by such a series of meetings. (02) The part of a year or of a day during which a school holds classes. (03) An assembly of people for a common purpose or because of a common interest: a gossip session. (04) Law A court of criminal jurisdiction in the United States: the court of sessions. (05) A period of time devoted to a specific activity, as to recording music in a studio.
Reference from: http://www.thefreedictionary.com/session

According to the oxford dictionary there are four general meanings for the word session they are 1. 2. 3. 4. A period of time that is spent doing a particular activity A formal meeting or series of meetings of a court, a parliament etc. ;a period of time when such meetings are held. A school or university year. An occasion when people meet to play music.

Introduction of session
According to Wikipedia session a conversation or a meeting, between two or more communicating devices, or between a computer and user (example: Login session) between computer and user.

Analysis
PHP Sessions
When you opening an application in your computer and do some change and then you will closed it that period of time call session. The problem is computer will know who you are, but server does not know who you are and what you do, because the HTTP address doesn't maintain state. So here PHP session will give you the answer

A PHP session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application.

A PHP session will allowing you to store user information on the server for later use (i.e. username, shopping items, etc). 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. 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.

What is a cookie (in PHP)


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.

The way of creating a cookie


Syntax:<html> <body> <?php setcookie("user", "nimal", time()+3600); ?> </body> </html>

Further reference for cookie: http://www.w3schools.com/php/php_cookies.asp

Way of Starting a PHP Session


Note: The session_start() function must appear BEFORE the <html> tag:
<?php session_start(); // store session data $_SESSION['views']=1; ?> <html> <body> <?php //retrieve session data echo "Pageviews=". $_SESSION['views']; ?> </body> </html>

The code above will register the user's session with the server, allow you to start saving user information, and assign a UID for that user's session. Destroying a Session
If you wish to delete some session data, you can use the unset() or the session_destroy() function.

The unset() function is used to free the specified session variable:


<?php unset($_SESSION['views']); ?>

destroy the session by calling the session_destroy() function:


<?php session_destroy(); ?>

ASP session
ASP session also similar to PHP but there are many differences between PHP & ASP among those, two differences as follows

Cost
To run ASP programs one needs IIS installed on a Windows platform server, which is not free. PHP programs run on Linux, which is free. Even the connectivity of the database is expensive in the case of ASP as MS-SQL is a product of Microsoft that needs to be purchased. PHP generally uses MySQL, which is freely available.

Speed
If we compare the speed of ASP and PHP then PHP has an upper hand. PHP code runs faster than ASP. ASP is built on COM based architecture, which is an overhead for the server whereas...

When session start with:A new user requests an ASP file, and the Global.as a file includes a Session_On Start procedure

A value is stored in a Session variable

A user requests an ASP file, and the Global.asa file uses the <object> tag to instantiate an object with session scope

How to Session End

A session ends if a user has not requested or refreshed a page in the application for a specified period. By default, this is 20 minutes. If you want to set a timeout interval that is shorter or longer than the default, use the Timeout property. The example below sets a timeout interval of 5 minutes:
<% Session.Timeout=5 %>

Store and Retrieve Session Variables

The most important thing about the Session object is that you can store variables in it.

The example below will set the Session variable username to "nimal" and the Session variable age to "50":
<% Session("username")="nimal" Session("age")=50 %>

Further references :- http://www.w3schools.com/asp/asp_sessions.asp

References WWW.W3scools.com www.wikipedia.com

Potrebbero piacerti anche