session_set_save_handler

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

session_set_save_handler

Post by user___ »

Hi guys,
I have functions which are used for storing, reading, and destroying sessions in a database but I get an error when I session_start() and try to set one after I have called session_set_save_handler(...My Functions...).
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post by user___ »

Hi guys,
Sorry for misleading you. I have found the bug. It is in the following code:

Code: Select all

/*******************************************************************************************************/
//Vars and Arrs
$var_names = array();
$referer = "";
$host = "";
$host_arr = array();
$file_num = 0;//int
$file = "";
/*******************************************************************************************************/

/*******************************************************************************************************/
//Check where a request came from
$referer = $_SERVER["HTTP_REFERER"];

//Extract the host only(Domain)
$host = str_replace("http://", "", $referer);
$host = str_replace("www.", "", $host);
$host_arr = explode("/", $host);
$host = $host_arr[0];

//Check
if(!strcmp($host, $HOST_DOMAIN)) {
}
else {
	exit()
}
/*******************************************************************************************************/

Code: Select all

Do you spot an error?
Can this cause my sessions not to run?
Any suggestions?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Did you find the bug, or do you assume that it's in this block? I don't see anything here that would cause your sessions to explode, though you might use parse_url() to extract the host from HTTP_REFERER instead.
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post by user___ »

Yes, I did but I do thank you for your help.
Post Reply