l7hope Posted August 11, 2008 Share Posted August 11, 2008 Hello everyone! I'm working on a login script that uses sessions, and I'm running into a few problems. I have everything working, however, if I'm logged in at http://example.net I will not be logged in at http://www.example.net. Which is a big problem for me because a lot of links use the www. and a lot don't. Is there any way that I can make it so that I'll be logged in on both? The top of my page looks like this: session_start(); if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID'])=='')) { header("location: http://www.example.net/access-denied.php"); exit(); } Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/119190-solved-session-errors/ Share on other sites More sharing options...
dezkit Posted August 11, 2008 Share Posted August 11, 2008 impossible Link to comment https://forums.phpfreaks.com/topic/119190-solved-session-errors/#findComment-613835 Share on other sites More sharing options...
revraz Posted August 11, 2008 Share Posted August 11, 2008 There should be no reason that links use both for the same site, just use Relative paths and not Absolute. Link to comment https://forums.phpfreaks.com/topic/119190-solved-session-errors/#findComment-613838 Share on other sites More sharing options...
dezkit Posted August 11, 2008 Share Posted August 11, 2008 oops its possible, i thought that you wanted sessions from example.net to example.com silly me Link to comment https://forums.phpfreaks.com/topic/119190-solved-session-errors/#findComment-613845 Share on other sites More sharing options...
l7hope Posted August 11, 2008 Author Share Posted August 11, 2008 Umm, How would you go about doing it? ??? I can change all the links, It's just a pain! Thanks for the quick responses! Link to comment https://forums.phpfreaks.com/topic/119190-solved-session-errors/#findComment-613852 Share on other sites More sharing options...
revraz Posted August 11, 2008 Share Posted August 11, 2008 Set the session domain in the php.ini file Link to comment https://forums.phpfreaks.com/topic/119190-solved-session-errors/#findComment-613855 Share on other sites More sharing options...
l7hope Posted August 11, 2008 Author Share Posted August 11, 2008 Cool! Thanks! One thing though, I'm using 1&1 as my host, so I can't edit my PHP ini file. However, I look around, and it looks like if you upload a file called PHP.INI, it will read the setting from that. Is that true? If so, what would I put in it? session.domain = ??? Thank you so much! Link to comment https://forums.phpfreaks.com/topic/119190-solved-session-errors/#findComment-613868 Share on other sites More sharing options...
discomatt Posted August 11, 2008 Share Posted August 11, 2008 A much easier way to do this would be replace session_start(); with session_set_cookie_params ( NULL, NULL, '.yourdomain.com' ); session_start(); If it doesn't work with null values, then use session_get_cookie_params to fill the others with their default value. Link to comment https://forums.phpfreaks.com/topic/119190-solved-session-errors/#findComment-613885 Share on other sites More sharing options...
l7hope Posted August 11, 2008 Author Share Posted August 11, 2008 That worked! Thank you so much! Link to comment https://forums.phpfreaks.com/topic/119190-solved-session-errors/#findComment-613926 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.