Jump to content

[SOLVED] Odd problem with sessions


bsprogs

Recommended Posts

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

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

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...
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.