php session – PHP

  php

Q(Question):

My Php page get expired in 15 min of no activity. But I didn’t find any program code mentioning time limit for session expire. (I am sure)

So I thing it is default setting. How I can change it? I would like to set 2 hrs for session expire. And also after time limit i want to display message to user that ‘Seesion expired. Pls try again’ like that. After that page has to be loaded again. is it possible? How? Advance thanks. friends.

A(Answer):

take a look at that link

A(Answer):

There is no time limit for session expire. At the time of page load we start session I think we should write session at the very first line in our code <? session_start(); ?> and we can assign value to the seesion wherever we need in our page for axample at the time of button click like that.

A(Answer):

Pls , Can you explain, with little sample? Whether i need to place <? session_start(); ?> before </form>.. Thanks

A(Answer):

when using <? session_start(); ?> ..my variable values are reset. showing wrong answers.

A(Answer):

There is loads of examples on the page johny10151981 gave you. Just scroll down.

A(Answer):


<? session_start();
include("connection.php");
?>
<form id="form1" name="form1" method="get" action="">
<table width="22%" border="2">
<tr>
<td>Rate This Company</td>
</tr>
<tr>
<td><table width="200">
<tr>
<td><label>
<input type="radio" name="polling" value="2" />
Good
</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="polling" value="1" />
Poor
</label></td>
</tr>
</table>
<input type="submit" name="submit" value="VOTE" />
<label></label></td>
</tr>
<?
if($submit)
{
echo $_SESSION['Voted'];
if($_SESSION['Voted']=="")
{
$_SESSION['Voted'] =1;
$totalpoints = $_GET['polling'];
mysql_query("update polling set TotalPoints = TotalPoints + $totalpoints where ID ='1'");
}
else
{
?>
<script type="text/javascript">
alert("You Have Already Voted");
</script>
<script type="text/javascript">
window.location.href ="polling.php";
</script>
<?
}
}
?>
</table>
</form>

LEAVE A COMMENT