bsprogs Posted April 16, 2007 Share Posted April 16, 2007 I'm programming an online community / file hosting website. I have a video player like youtube and an image viewer like imageshack which are both executed in the view.php page on my website. When a user logs in, it will automatically regenerate their session_id. Now if what I've read about sessions is correct, going from http://www.mysite.com/member.php to http://www.mysite.com/view.php the site SHOULD keep the same session_id. For some reason the first time a user logs in and views an image or video, it will change their session id but when they log back in, they can roam about viewing any video or image they want and it never changes again. I even took the "session_regenerate_id()" line to see if that was somehow being executed but it didn't change anything! I'm thinking about implementing a token id for each user when they login instead if I can't figure this out. Any ideas what could cause session information to be changed? each page has session_start(); at the very top of the page Link to comment https://forums.phpfreaks.com/topic/47167-solved-odd-problem-with-sessions/ Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Share Posted April 16, 2007 you should have this at the top of every page: session_start(); session_register(); what's your code look like now? Link to comment https://forums.phpfreaks.com/topic/47167-solved-odd-problem-with-sessions/#findComment-230019 Share on other sites More sharing options...
bsprogs Posted April 16, 2007 Author Share Posted April 16, 2007 I think I figured out the problem. It seems that the problem isn't a PHP problem after all. I noticed that most people are accessing my site using: http://mydomain.com/index.php and when it goes to the view.php page, it goes to http://www.mydomain.com/view.php I need to setup a redirect so that if a user goes to mydomain.com it will send them to www.mydomain.com Link to comment https://forums.phpfreaks.com/topic/47167-solved-odd-problem-with-sessions/#findComment-230048 Share on other sites More sharing options...
bsprogs Posted April 16, 2007 Author Share Posted April 16, 2007 Ok, I fixed this. I just setup a simple redirect in PHP. <?php session_start(); session_register(); if ($_SERVER['HTTP_HOST'] != "www.mydomain.com") {?> <script language="JavaScript"> window.location = 'http://www.mydomain.com/'; </script> <?php } ... code here... ?> Link to comment https://forums.phpfreaks.com/topic/47167-solved-odd-problem-with-sessions/#findComment-230051 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.