How many ways can we get the value of current session id?How can we increase the execution time of a php script?How can we find the number of rows in a result set using PHP?What are the various methods to pass data from one web page to another web page?How many ways can we get the value of current session id?How to set cookies?How can we know that a session is started or not? ~ Interview Questions & Answers
6:47 PM
Using session_id() function, the current value of the session can be found.
Syntax:
String session_id(string $id);
6:34 PM
By the use of void set_time_limit(int seconds)
Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini. If seconds is set to zero, no time limit is imposed.
When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.
6:30 PM
Here is how can you find the number of rows in a result set in PHP:
$result = mysql_query($any_valid_sql, $database_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";
Different methods to pass data from one web page to another:
1. Store the data in a session variable. By storing the data, the data can be passed from one page to another.
2. Store data in a cookie: By storing data in a persistent cookie, data can be passed from one form to another.
3. Set the data in a hidden field and post the data using a submit button.
Using session_id() function, the current value of the session can be found.
Syntax:
String session_id(string $id)
setcookie('variable','value','time');
variable - name of the cookie variable
value - value of the cookie variable
time - expiry time
Example: setcookie('Test',$i,time()+3600);
Test - cookie variable name
$i - value of the variable 'Test'
time()+3600 - denotes that the cookie will expire after an one hour
Syntax:
bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )
6:35 PM
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().