[PHP] Sessions with register_globals = off
Am in need of help or I will loose my sanity!!! Im runnin Php 4.1.2 with Apache 1.3.22 on Win32 with register_globals set to off. My script is as follows: If I check the cookie, its completely empty. Now if I change this to: the cookie now contains: myVar|s:9:"Something"; This is annoying as everyhwhere I read about sessions, Im told that if register_globals is off, I shouldnt use session_register(), all I need to do is: $HTTP_SESSION_VARS["myVar"] = $myVar; or $_SESSION["myVar"] = $myVar; but neither work :( Finally, if I want to change the value of $HTTP_SESSION_VARS["myVar"] and carry that change over to the next page it doesnt work. For example, i have registered the session variable $myVar as above and can read it using $HTTP_SESSION_VARS["myVar"]. If I do: $HTTP_SESSION_VARS["myVar"] = "Some other text"; then $HTTP_SESSION_VARS["myVar"] contains that text, but only for this page! How do I use sessions then with register_globals = off???!!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] right place to start a session?
The session_start() needs to come before any code outputs anything to the browser, so in your case you need to put it before the and tags: Here's my code: > > > //trying to start a session right here for the usr and pwd variables > session_start(); > session_register("usr", "pwd"); > if (isset($login)): > ?> > go. I'm in need of a good samaritan here... > > Thanks! -Kirk > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session expires on server side
Aljosa Mohorovic wrote: > session cookie exists on client side and it is set to last 5 days. > the problem is that after some time session data expires. cookie > on client side exists ($PHPSESSID), but session data on server side > does not exists. > > i think that the answer is something like: > ini_set("session.cache_expire", "7200"); > but i'm not sure. i need this fast, so thnx > to anybody with a solution. > > Aljosa > > P.S. > sorry for my bad english, here is the code: Not too sure. Try messing with session.gc_maxlifetime. According to the php manual, this sets the length of time (in secs) before session data is cleared with the garbage collection routine. Padraig > -- > $time = (60*60*24*5); > > ini_set("session.cache_expire", "7200"); > > $date = gmdate ("D, d M Y H:i:s") . " GMT"; > header ("Date: " . $date); > header ("Expires: " . $date); > header ("Last-Modified: " . $date); > header ("Pragma: no-cache"); > header ("Cache-Control: no-cache"); > > session_set_cookie_params($time); > ?> > -- > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php