oceans Posted May 17, 2007 Share Posted May 17, 2007 Dear Friends, Can anyone suggest how I can make a Session like variable to be a permanent one? What I mean is, session variables will die after a client ceases to be around; what I want is, this variable should be always around from the time server is turned on till of, please don’t suggest MySQL. I want a memory slot. In ASP we can use “Global.asa” Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/ Share on other sites More sharing options...
mpharo Posted May 17, 2007 Share Posted May 17, 2007 what you want are $_SERVER variables... http://us.php.net/reserved.variables Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255037 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 Dear Frined, I ran through your article, it did not gave any examples on how to use syntex. I just want to (1) create a variable, (2) assign a value to it, (3) read the value. Thanks Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255043 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 Dear Friends, Honest, I do not know how to do this. Pease Help. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255049 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 Do you want this variable to be specific to a user? Use cookies. Otherwise, just set the variable within an include and include it. there is nothing like the global.asa file in php. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255054 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 Ok, Please guide me with an example, This variable is NOT tied to anyone in particular at all, this varible is always there, any client can view it and change it. I know it is simple, but I am lost a bit. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255066 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 permvar.php <?php $var = 'foo'; ?> anyotherfile.php <?php include 'permvar.php'; echo $var; ?> Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255069 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 OK, I think you are asking me to make a file called "permvar.php" declare a variable there. After which include the file, the respecitve pages that require this variable. Am I right? Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255072 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 That is correct. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255074 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 Thanks Thrope, I will try. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255076 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 Nope, I can't change the value at run time. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255091 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 Any one could help me please. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255108 Share on other sites More sharing options...
radar Posted May 17, 2007 Share Posted May 17, 2007 Run it such as this... <?php $variable = 'foo'; ?> then if you wish for the user to be able to edit the variable it would depend on how you wish for them to edit the variable... <?php $variable = 'foo'; $switch ($act) { case act: $variable = $_REQUEST['textfield']; break; } ?> <form name="form1" method="post" action="?act=edit"> <label> <input type="text" name="textfield"> </label> <label> <input type="submit" name="Submit" value="Submit"> </label> </form> and that would set the thing to foo, and then when you use the form it would update it to whatever you want... perhaps this is what you want? Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255114 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 Dear Radar, Thanks for your help. I will tell you my idea. I will gave ONE global variable ((i)session type[varible to reside in server], (ii)assesible to all clients, (iii)variable value should be changable at run time by all clients) please advice a method that will help me thanks. I squeezed my brain but not getting anywhere, with ASP yes it is possible; PHP I can't figure out. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255118 Share on other sites More sharing options...
radar Posted May 17, 2007 Share Posted May 17, 2007 I don't know a lot about ASP but with PHP to make a global session to my knowledge is impossible in PHP... The only other way i could think about doing it would be to use a flat-file since you don't want to use mysql (which i use for everything).... I did a spot of searching and i found this for you... http://koivi.com/manual-php-globals/ it doesn't go into a whole lot of detail but might be more along the lines of what you are looking for. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255120 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 Friend thanks for your sweat I will work on it. I can use MySQL, but the resource over head to too much in relation, that is why I prefer memory slot. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255124 Share on other sites More sharing options...
radar Posted May 17, 2007 Share Posted May 17, 2007 I will keep you in mind as i run across any other information on this subject. As for sweat, no way -- PHP is my life, i develop websites professionally and use PHP as my foundation -- and so without PHP I would die. Speaking of -- take a look at this right here -- might have some useful information for you. http://www.onlamp.com/pub/a/php/2004/05/13/shared_memory.html Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255127 Share on other sites More sharing options...
oceans Posted May 17, 2007 Author Share Posted May 17, 2007 Thanks Friend, You may send me PM," Oceans" If will work on it. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255129 Share on other sites More sharing options...
mpharo Posted May 17, 2007 Share Posted May 17, 2007 Resource overhead of MySQL? it takes miliseconds to return a result and has less than 1% utilization on a low end server...there is no great overhead for a single query to grab one result?? Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255355 Share on other sites More sharing options...
sKunKbad Posted May 17, 2007 Share Posted May 17, 2007 Just set the session cookie to expire later. The first argument to session_set_cookie_params is the number of seconds in the future (based on the server's current time) that the session will expire. So if you want your sessions to last 100 days: $expireTime = 60*60*24*100; // 100 days session_set_cookie_params($expireTime); Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-255448 Share on other sites More sharing options...
oceans Posted May 22, 2007 Author Share Posted May 22, 2007 Dear Experts, I sincerely want help. OK, I will tell you what is in my mind. I am going to use this particular variable as a gate flag. When gate flag is ok, all cliants get to work on server, if not, no. I am extanding this idea from my own server programe, I made earlier. I can implement using Global.ASA in asp, but I am looking for something similar in PHP. I appreciate your experience thanks. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-258798 Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 but I am looking for something similar in PHP. There is nothing similar in PHP. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-258872 Share on other sites More sharing options...
oceans Posted May 23, 2007 Author Share Posted May 23, 2007 :'( Yes I agree, I very tried hard too. OK can any one suggest a method on how could I implement. One of the two reason I need this. If I want to turn off server, I should not simply OFF, I should allow "all already in clients" to complete what they are there for, at the same time block new hook ons, if not "all already in clients" will loose unprocessed data. Please I will take any suggestions. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-259553 Share on other sites More sharing options...
trq Posted May 23, 2007 Share Posted May 23, 2007 What is wrong with the suggestions already posted. If you want values to persist, store them in something made for storing data. ie; A database. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-259555 Share on other sites More sharing options...
oceans Posted May 23, 2007 Author Share Posted May 23, 2007 Thrope, I tried your suggestion, but I can't change the value and store back at run time, that means, the value it always a constant. Link to comment https://forums.phpfreaks.com/topic/51770-permanent-session-variable/#findComment-259561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.