dckarina Posted June 6, 2006 Share Posted June 6, 2006 when i use session_start() it creates a new session even if i have already opened a session. i have 2 php files. <?phpsession_start();echo session_id();echo "<a href=page2.php>next page</a>"?>page2.php<?phpsession_start();echo session_id();?>the session id is different for each file. please help me. Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/ Share on other sites More sharing options...
trq Posted June 6, 2006 Share Posted June 6, 2006 Are you sure cookies are enabled in your browser? Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42328 Share on other sites More sharing options...
dckarina Posted June 6, 2006 Author Share Posted June 6, 2006 yes,i'm sure. i checked. and on some computers it works ok but on others it doesn't.and i used mozilla on all. Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42346 Share on other sites More sharing options...
dckarina Posted June 6, 2006 Author Share Posted June 6, 2006 no idea why this is happening?i really need this so i can work on my own computer. so any ideas may be usefullKarina Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42400 Share on other sites More sharing options...
poirot Posted June 6, 2006 Share Posted June 6, 2006 Maybe it's a IE6 bug.Try to add a header:[code]header("Cache-control: private");[/code]Right after session_start() Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42408 Share on other sites More sharing options...
kenrbnsn Posted June 6, 2006 Share Posted June 6, 2006 What web server? I've heard the IIS has problems with sessions.Ken Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42431 Share on other sites More sharing options...
dckarina Posted June 6, 2006 Author Share Posted June 6, 2006 [!--quoteo(post=380597:date=Jun 6 2006, 04:46 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 6 2006, 04:46 PM) [snapback]380597[/snapback][/div][div class=\'quotemain\'][!--quotec--]Maybe it's a IE6 bug.Try to add a header:[code]header("Cache-control: private");[/code]Right after session_start()[/quote]i added that too.still not working.10x anywaykarina[!--quoteo(post=380621:date=Jun 6 2006, 05:53 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Jun 6 2006, 05:53 PM) [snapback]380621[/snapback][/div][div class=\'quotemain\'][!--quotec--]What web server? I've heard the IIS has problems with sessions.Ken[/quote]I use XAMPP.it has Apache and Mysql.But i have XAMPP where I work and there I have no problems with sessions. I didn't have to configure anything, I just had to install it. It's the same version but for some reason on another computer i have problems with sessions.Karina Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42444 Share on other sites More sharing options...
AndyB Posted June 6, 2006 Share Posted June 6, 2006 If this works perfectly when accessed from 'some' computers and doesn't work when accessed from 'other' computers, then I would assume initially that the problem lies with the client machine browser/browser settings and not that there's a problem with the server or server-side coding.That said, the fact that a client-side set-up can adversely affect your server-side coding's performance suggests you need to adjust the server-side code to compensate for the client-side differences (because those are sure to crop up over and over again and you can't exert any sensible control over client preferences).If it works some of the time and fails some of the time using the [b]same[/b] client machine and browser then there's a problem with your server-side scripting.It [i]may[/i] be worth testing performance with the same client machine running different browsers. Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42447 Share on other sites More sharing options...
dckarina Posted June 6, 2006 Author Share Posted June 6, 2006 [!--quoteo(post=380637:date=Jun 6 2006, 06:53 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 6 2006, 06:53 PM) [snapback]380637[/snapback][/div][div class=\'quotemain\'][!--quotec--]If this works perfectly when accessed from 'some' computers and doesn't work when accessed from 'other' computers, then I would assume initially that the problem lies with the client machine browser/browser settings and not that there's a problem with the server or server-side coding.That said, the fact that a client-side set-up can adversely affect your server-side coding's performance suggests you need to adjust the server-side code to compensate for the client-side differences (because those are sure to crop up over and over again and you can't exert any sensible control over client preferences).If it works some of the time and fails some of the time using the [b]same[/b] client machine and browser then there's a problem with your server-side scripting.It [i]may[/i] be worth testing performance with the same client machine running different browsers.[/quote]i used IE and Mozilla on the same computer. The same result. I'm out of ideas.Karina Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42453 Share on other sites More sharing options...
kenrbnsn Posted June 6, 2006 Share Posted June 6, 2006 Take a look in the PHP.INI file. Make sure the directory that the session manager wants to use is really there and is writable.Ken Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42475 Share on other sites More sharing options...
dckarina Posted June 6, 2006 Author Share Posted June 6, 2006 [!--quoteo(post=380665:date=Jun 6 2006, 08:02 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Jun 6 2006, 08:02 PM) [snapback]380665[/snapback][/div][div class=\'quotemain\'][!--quotec--]Take a look in the PHP.INI file. Make sure the directory that the session manager wants to use is really there and is writable.Ken[/quote]what exactly i'm looking for? what session. ...?i don't really know how to configure php.ini. I have xampp. I only had to installKarina Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42514 Share on other sites More sharing options...
kenrbnsn Posted June 6, 2006 Share Posted June 6, 2006 I run xampp on my laptop.Create a php script named info.php in a directory you use for your scripts which contains:[code]<?phpp.hpinfo();?>[/code](remove the period from p.hpinfo)Invoke the script via a browser and look for the line that starts "[b]Configuration File (php.ini) Path[/b]". On my display it is the sixth line. Note the value in the right column. That value on my machine is "C:\Program Files\xampp\apache\bin\php.ini"Open that file in notepad or your favorite editor and look for the line that starts with "session.save_path". There should be a directory there. Check that the directory exists and is not marked "read only".Ken Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42530 Share on other sites More sharing options...
dckarina Posted June 6, 2006 Author Share Posted June 6, 2006 [!--quoteo(post=380721:date=Jun 6 2006, 09:41 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Jun 6 2006, 09:41 PM) [snapback]380721[/snapback][/div][div class=\'quotemain\'][!--quotec--]I run xampp on my laptop.Create a php script named info.php in a directory you use for your scripts which contains:[code]<?phpp.hpinfo();?>[/code](remove the period from p.hpinfo)Invoke the script via a browser and look for the line that starts "[b]Configuration File (php.ini) Path[/b]". On my display it is the sixth line. Note the value in the right column. That value on my machine is "C:\Program Files\xampp\apache\bin\php.ini"Open that file in notepad or your favorite editor and look for the line that starts with "session.save_path". There should be a directory there. Check that the directory exists and is not marked "read only".Ken[/quote]the directory exists but it's marked read-only. what should i do? i'm using wamp server now if it helpsthere is a session.save_handler=files and it says something that windows user should modify it but i don't really understand how. Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42544 Share on other sites More sharing options...
.josh Posted June 7, 2006 Share Posted June 7, 2006 so..you can't rightclick > properties > change it from read only to writeable? Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42659 Share on other sites More sharing options...
Ferenc Posted June 7, 2006 Share Posted June 7, 2006 You are making this more of a pain than it needs to be.sessions, and all other things you want a server to store are saved in /tmp (/temp) by default (if it exists).if not defined in the php.ini, php looks to the defaut temp dirdectory(/temp..../tmp)Windows temp directory is C:\Documents and Settings\USER_NAME\Local Settings\Tempthe problem with windows....apache doesn't have access. This is a good thing!You can adjust things so the user stores ther session via a cookie, but that isn't always possible....or wiseSimply edit the session store path directory in the php.in to C:/tempthen make the folder temp in C:\read more [a href=\"http://us2.php.net/manual/da/ref.session.php\" target=\"_blank\"]here[/a] Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42681 Share on other sites More sharing options...
dckarina Posted June 7, 2006 Author Share Posted June 7, 2006 [!--quoteo(post=380853:date=Jun 7 2006, 06:53 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 7 2006, 06:53 AM) [snapback]380853[/snapback][/div][div class=\'quotemain\'][!--quotec--]so..you can't rightclick > properties > change it from read only to writeable?[/quote]no.i can't change it. but i don't think that is the problem. i tried it on another computer which has the same path and the directory is the same - read-only- but it works, it doesn't create a new session when i click the link Quote Link to comment https://forums.phpfreaks.com/topic/11305-problem-with-session_start/#findComment-42698 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.