Hi there,
I have a page that have the following code:
<?
if (!isset($SID))
{
$SID = mt_rand();
echo $SID;
}
else
{
echo "SID already set";
}
?>
The problem is everytime I hit refresh button (F5) the variable is re-created! I want only to create that variable only if its the first time the user enter that page.
Please I appreciate your help.
isset() Problem
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Where does $SID come from?
Depending on the answer to the above this may help:
viewtopic.php?t=511
Mac
Depending on the answer to the above this may help:
viewtopic.php?t=511
Mac
Forget that SID is SessionID, assume it any varibale (lets say ID) and I want this variable (ID) to be careated once, and when the user hit the refresh button (F5) it will not be re-created.
So the code will be:
<?
if (!isset($ID))
{
$ID = mt_rand();
echo $ID;
}
else
{
echo "ID already set";
}
?>
One more thing I dont want to use session_start() becuse this command requires a cookie, and maybe the user disabled the cookies on his/her PC.
Please I apreciate you help.
So the code will be:
<?
if (!isset($ID))
{
$ID = mt_rand();
echo $ID;
}
else
{
echo "ID already set";
}
?>
One more thing I dont want to use session_start() becuse this command requires a cookie, and maybe the user disabled the cookies on his/her PC.
Please I apreciate you help.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
I can't remember which PHP's version that my webHost is using, but what I can remember very good that the PHP's version that my webHost is using is if the cookie is disabled the variable will not be inserted in the URL automatically! from this point I dont want to use sessions.
So, is there is any way to stop re-creating (ID) variable everytime the user hit the refresh button?
I know that in PHP you can play around anything and implement your crazy idea:)
So, is there is any way to stop re-creating (ID) variable everytime the user hit the refresh button?
I know that in PHP you can play around anything and implement your crazy idea:)
-
superwormy
- Forum Commoner
- Posts: 67
- Joined: Fri Oct 04, 2002 9:25 am
- Location: CT
YOu need to have a way of identifying the client and setting the SID for that client, then having the client passign the SID to each page they visit.
You can only do this by setting a session cookie or generic cookie, or passing it through the URL.
If you don't do one of those things, then no, there is no way to stop it from recreating a new session each time.
You can only do this by setting a session cookie or generic cookie, or passing it through the URL.
If you don't do one of those things, then no, there is no way to stop it from recreating a new session each time.