16 April 2011

interview question : sessions php

Q) How can we know that a session is started or not?

Ans:A session starts by session_start() function.
This session_start() is always declared in header portion. it always declares first. then we write session_register().

References:

 http://php.net/manual/en/function.session-register.php
Faculty Name:Saritha G Pillai


Q) If we login more than one browser windows at the same time with same user and after that we close one window, then is the session is exist to other windows or not? And if yes then why? If no then why?

Ans:Session depends on browser. If browser is closed then session is lost. The session data will be deleted after session time out. If connection is lost and you recreate connection, then session will continue in the browser.

References:

 http://php.net/manual/en/function.session-register.php
Faculty Name:Saritha G Pillai

Q) Difference between session_register and $_SESSION for registering session variable in php?

Ans: session_register() is a function and $_SESSION is a superglobal array.

session_register() is used to register a session variable and it works only when register_globals is turned on. (Turning ON register_globals will create mesh-ups, but some applications (e.g OScommerce) requires turning ON of register_globals). But $_SESSION works even when register_globals is turned off.

If session_start() was not called before session_register() is called, an implicit call to session_start() with no parameters will be made. But $_SESSION requires session_start() before use.

session_register function returns boolean value and $_SESSION returns string value

session_register() function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0.

References:

http://www.webestilo.com/en/php/php12c.phtml
Faculty Name:Viji.V


Q) How can we start a session ?

Ans:A session starts by session_start() function.
This session_start() is always declared in header portion. it always declares first. then we write session_register().

References:

http://php.net/manual/en/function.session-register.php

http://www.phptutorial.info/learn/session.php

http://www.webestilo.com/en/php/php12c.phtml


For the latest IT jobs visit  www.ipsrjobs.com 

No comments:

Post a Comment