Jump to content

[SOLVED] Session errors.


l7hope

Recommended Posts

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

Cool! Thanks! ;D

 

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! ;D

 

 

 

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.

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.