Create session (first line of PHP script)
I read session data like this
| Code: |
| $this->name = $_SESSION["sess_name"]; |
I write session data like this
| Code: |
| $_SESSION["sess_name"] = $this->name; |
and I destroy session, when the user log-out like this
| Code: |
session_destroy();
$_SESSION = array();
|
What am I dooing wrong?
With Frihost, I have many problems with sessions. The session lifetime is too short (about one minute).
What could I improve, or what global variables (that I perhaps rewrite) modifies session params?
I don't think there is any thing wrong with your code, but you might have placed some code in wrong place. For example, you might have accidently put
or
| Code: |
| $_SESSION = array(); |
somewhere in one of your php file, visiting which might be terminating your session.
I am using the php session on frihost since I got hosting here and I haven't faced any problem till now.
But I´ve got the same Problem! Wait a second, I´ll read out the
session.gc_maxlifetime...
I´ve got it:
try putting
| Code: |
| ini_set('session.gc_maxlifetime',3600); |
at the beginning of your script, it works!
(for 3600, type the seconds your session should be alive)
Hm, It´s not really the solution... it worked once....
So now I read out the lifetime with
| Code: |
| echo (ini_get('session.gc_maxlifetime')) |
, and php said 1440. But the time till the session dies is NEVER 24 mins!!
Double check that you didn't mess with the session like they said. Or maybe make a dummy page with simple session tests to see if it lasts 24 minutes.
Sessions are working for me without any problem.
I think your code has got an error. Post it so we can look for it.
I cant post my code, its so huge.
thank you, I will recack the code. When I solve the problem, I will post the sollution.
BTW, does anyone know, how to "switch off" registrglobals on frihost?
| JayBee wrote: |
I cant post my code, its so huge.
thank you, I will recack the code. When I solve the problem, I will post the sollution.
BTW, does anyone know, how to "switch off" registrglobals on frihost? |
Sort of lame they are on but
| Quote: |
register_globals boolean
Whether or not to register the EGPCS (Environment, GET, POST, Cookie, Server) variables as global variables.
As of PHP 4.2.0, this directive defaults to off.
Please read the security chapter on Using register_globals for related information.
Please note that register_globals cannot be set at runtime (ini_set()). Although, you can use .htaccess if your host allows it as described above. An example .htaccess entry: php_flag register_globals off.
Note: register_globals is affected by the variables_order directive. |
from php.net, so you can use .htaccess maybe?
| snowboardalliance wrote: |
| ... from php.net, so you can use .htaccess maybe? |
Thank you
I thing, that partly solve my problems
I know this subject is not recently started, but I had the same problem. I searched a lot about it and finally it seems to be a very stupid fault...
Not everything in PHP seems to be case-sensitive, but working with sessions is case-sensitive. So, if you want to start a session, use: SESSION_START();. If you want to stop a session, use: SESSION_DESTROY();.
I hope this will help a lot of people handling with the same session problem.
Greetz
That would be odd and I'm sure I've seen working code with it in lower case, and the topic creator's code wouldn't work at all if what you're saying was right.