oceans Posted June 5, 2007 Share Posted June 5, 2007 Dear Friends, I asked and did a lot of experiments on sessions. The following is what I found: When two or more client programs are open from the SAME computer, there are NO multiple session files but only one, thus the server uses the same data set from a single session file for all the client programs from the SAME computer, this is disaster! How can I overcome, please? I use the following: ob_start(); session_start(); $NumberOfSessionVariables=4; for ($i=1; $i<=$NumberOfSessionVariables; $i++) { $_SESSION['14ForView'.$i]=0; } I also noted, my WAMP server does not removes the session files after the client has left. One of our fiends has suggested me: http://sg2.php.net/session_destroy I think,if I were to permanently set the time out for a session in the ini file, it should be far better, can any one teach me what line should I edit in the ini file. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/ Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 One thing you can give session variables name like this projectsortname_loginemail,projectsortname_userid. Another thing you need to set session id each time to start session. Your above mention problem is in which browser. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268098 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 Dear Jitesh, My clients are in IE, and I am using WAMP in the same computer. I will not be able to use loginuserid, because two clents will have the same. But your second solution sounds warm, can you explain, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268106 Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 Like this <?php $example = "3242sfs3245242"; // This is the session id which is generated when you you first time start the session session_id($ezample); session_start(); ?> In this case you need to pass session id in each page when you redirect either in query string or through post . Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268116 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 Do you mean I should have this ob_start(); $example = "3242sfs3245242"; // This is the session id which is generated when you you first time start the session session_id($example); session_start(); $NumberOfSessionVariables=4; for ($i=1; $i<=$NumberOfSessionVariables; $i++) { $_SESSION['14ForView'.$i]=0; } how do i call the session is it like this $value=$_SESSION['14ForView1']; or some thing else? Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268122 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 Oh No, Jitesh left, can any one help me futher. I tried putting my own session id, this might not work for me, it gives that same problem. Can any one suggest Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268124 Share on other sites More sharing options...
mmarif4u Posted June 5, 2007 Share Posted June 5, 2007 i think u have to store it like this: $value=$_SESSION['14ForView1.$i'] Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268126 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 Mmarif4u, Yes, my syntex is correct, I just confirmed, please help me with my problem. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268129 Share on other sites More sharing options...
mmarif4u Posted June 5, 2007 Share Posted June 5, 2007 I did not check it but i think it is correct to unset the values. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268133 Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 I do not mean to set session_id in session variable It may be like this http://www.domain.com/index.php?session_id=s3f34er345ff3453f34534 --------------------------------------------------------------------- Now in index.php file set <?php session_id($_GET['session_id']); session_start(); .............. ............. .............. ?> in this case you should have session id all time. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268136 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 Dear Jitesh, I am confused, please bare with me. this is what i have in my index.php <?php header('location:112/Home.php'); ?> that is all. you want me to do this <?php ob_start(); header('location:112/Home.php'); session_id($_GET['session_id']); session_start(); ?> am I right well on the other pages I do not do any thing, if I start new variables for the respective pages, i leave them as ob_start(); session_start(); $NumberOfSessionVariables=4; for ($i=1; $i<=$NumberOfSessionVariables; $i++) { $_SESSION['14ForView'.$i]=0; } Will I be ok? Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268144 Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 <?php ob_start(); header('location:112/Home.php?session_id=$_GET['session_id']); ?> ------------------------------------------------------------- Other page ob_start(); ----------------------------- session_id($_GET['session_id']); // You need to set session id before session start each time. (which is created when you have first time start session) ----------------------------- session_start(); $NumberOfSessionVariables=4; for ($i=1; $i<=$NumberOfSessionVariables; $i++) { $_SESSION['14ForView'.$i]=0; } in simple word the flow is with two line sessiion_id('.....'); session_start(); Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268147 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 Dear Jitesh, I think there could be a typo in your <?php ob_start(); header('location:112/Home.php?session_id=$_GET['session_id']); ?> I get the following error " Parse error: syntax error, unexpected T_STRING in C:\wamp\www\Index.php on line 3 " by the way even if we were to do your method, am I right to say the id number will be the same always for all computers, i may be wrong. correct me. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268151 Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 header('location:112/Home.php?session_id='.$_GET['session_id']); Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268152 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 ok index went through now my page i get the following error " Warning: session_start() [function.session-start]: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in C:\wamp\www\113\1401View.php on line 5 " line 5 refers to "session_start();" Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268156 Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 You do not need to dynamic set session id. When you will first time start session it will create a session id. that session id you need to pass in query string and pass to api session_id like this session_id($_GET['session_id']); Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268159 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 Dear Jitesh, I did exectly what you wrote i got the error, could there be a typo in your instructions for my work page. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268160 Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 post the value you found as a session id Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268162 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 sess_a20d5d57251f75308adc73dfc2f780b3 this is the file name Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268163 Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 i meant like this session_id('a20d5d57251f75308adc73dfc2f780b3'); session_start(); When first time set session get seted session id as echo session_id(); $set_session_id = session_id(); Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268170 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 Friend can you please correct my page side code for me, thanks. I can't get you honest. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268173 Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 <?php ob_start(); session_start(); // when first time set session $this_is_set_session_id = session_id(); header('location:112/Home.php?session_id='.$this_is_set_session_id); ?> ------------------------------------------------------------- Home.php ob_start(); ----------------------------- // If session is set then use previous set session by old session id otherwise start new session $this_is_set_session_id = isset($_GET['session_id'])?$_GET['session_id']:""; session_id($this_is_set_session_id); ----------------------------- session_start(); $NumberOfSessionVariables=4; for ($i=1; $i<=$NumberOfSessionVariables; $i++) { $_SESSION['14ForView'.$i]=0; } Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268174 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 Friend, what I noted, when the index pages starts i get one file, when the home page starts i get one more file. the error on the home page " Warning: session_start() [function.session-start]: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in C:\wamp\www\113\1401View.php on line 7 " line 7 refers to "session_start();" Thanks for being with me friend. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268175 Share on other sites More sharing options...
jitesh Posted June 5, 2007 Share Posted June 5, 2007 post 1401View.php and a file before 1401View.php and a file where you have first time set session. Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268176 Share on other sites More sharing options...
oceans Posted June 5, 2007 Author Share Posted June 5, 2007 I will let you know the full story. I have about 50 of pages grouped into 5 catagory. For each catagory, I will get user name and other info independent to other catagory, keep them alive in in sessions till the user goes to the end of the catagory, and i will unset the sessions at the last page. Thus I have 5 sets of sesions variables. This is what i do every time I need to start a catagory, i will do the following: ob_start(); session_start(); $NumberOfSessionVariables=4; for ($i=1; $i<=$NumberOfSessionVariables; $i++) { $_SESSION['xxxxxxx'.$i]=0; } xxxxxx is the catagory name, I have 5 names. please read i will extract and post your request... Quote Link to comment https://forums.phpfreaks.com/topic/54228-solved-experiments-on-session/#findComment-268183 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.