I'm trying to maintain some session variables across pages in php.<br /><br />Does it make a difference if the variables are stored across pages wehre I go back and forth between "www" and without?<br /><br />What I mean is, if I store some strings into session variables using a page called "****/pagename.php", then if I link the user to "<b>www</b>.****/page2.php" would that cause those session variables to be lost?<!--content-->
Shouldn't be lost. With cookies I've noticed that it really depends on how you set the cookie, and that there is a way to make it work whether www or not.<br /><br />php.net is a great resource on these kinds of questions. The user input is really a goldmine.<!--content-->
<!--quoteo(post=166847:date=Feb 18 2006, 08:18 PM:name=surefire)--><div class='quotetop'>QUOTE(surefire @ Feb 18 2006, 08:18 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=166847"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->Shouldn't be lost.<!--QuoteEnd--></div><!--QuoteEEnd--><br />Second that. Why, are you having problems?<!--content-->
I was helping someone else with this issue. Actually the variables were being passed in the URL string in a non-www URL, and going to a URL with www, we thought that may be the problem. Just wondering if anyone here might be able to confirm if that is the case.<br /><br />For example, going from http--domainDotcom/file.php?col=bl&img=default&c=4&i=1 and then go to http--wwwDotdomainDotcom/file.php returns all empty strings from session vars.<!--content-->
some testing around I've done proves that yes, switching to a hard-coded link to a "www" URL when you are coming from a URL that does not have "www" drops the session values. SessionID is in fact retained, but the values held in session are lost!<br /><br />Try it out here: renkai.com<!--content-->
A session is a type of cookie. As I said:<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->With cookies I've noticed that it really depends on how you set the cookie, and that there is a way to make it work whether www or not.<br /><br />php.net is a great resource on these kinds of questions.<!--QuoteEnd--></div><!--QuoteEEnd--> <br /><br />A little research and I've solved your problem:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$url = 'yoursite.com';// leave off www and http:// !!!!!!<br /><br />session_set_cookie_params(0,'/', '.'.$url,'');<br /><br />session_start();<!--c2--></div><!--ec2--> <br /><br />I have tested on my own server.<!--content-->
Shouldn't be lost. With cookies I've noticed that it really depends on how you set the cookie, and that there is a way to make it work whether www or not.<br /><br />php.net is a great resource on these kinds of questions. The user input is really a goldmine.<!--content-->
<!--quoteo(post=166847:date=Feb 18 2006, 08:18 PM:name=surefire)--><div class='quotetop'>QUOTE(surefire @ Feb 18 2006, 08:18 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=166847"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->Shouldn't be lost.<!--QuoteEnd--></div><!--QuoteEEnd--><br />Second that. Why, are you having problems?<!--content-->
I was helping someone else with this issue. Actually the variables were being passed in the URL string in a non-www URL, and going to a URL with www, we thought that may be the problem. Just wondering if anyone here might be able to confirm if that is the case.<br /><br />For example, going from http--domainDotcom/file.php?col=bl&img=default&c=4&i=1 and then go to http--wwwDotdomainDotcom/file.php returns all empty strings from session vars.<!--content-->
some testing around I've done proves that yes, switching to a hard-coded link to a "www" URL when you are coming from a URL that does not have "www" drops the session values. SessionID is in fact retained, but the values held in session are lost!<br /><br />Try it out here: renkai.com<!--content-->
A session is a type of cookie. As I said:<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->With cookies I've noticed that it really depends on how you set the cookie, and that there is a way to make it work whether www or not.<br /><br />php.net is a great resource on these kinds of questions.<!--QuoteEnd--></div><!--QuoteEEnd--> <br /><br />A little research and I've solved your problem:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$url = 'yoursite.com';// leave off www and http:// !!!!!!<br /><br />session_set_cookie_params(0,'/', '.'.$url,'');<br /><br />session_start();<!--c2--></div><!--ec2--> <br /><br />I have tested on my own server.<!--content-->