Jump to content

Session not working


The Little Guy

Recommended Posts

I am using AJAX to access this file on my domain (weblyize.com), from my subdomain (ping.weblyize.com), and it keeps going into the if statement, logged is set on the domain, because I can see it when I go to a page that displays it. Anyone know why it is going into the if? If I go to the page directly, it works fine.

 

header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET");
header("Access-Control-Allow-Headers: NCZ");
header("Access-Control-Max-Age: 1728000");
session_set_cookie_params(0, "/", ".weblyize.com", false); 
session_start();
if(!isset($_SESSION['logged']) || !$_SESSION['logged']){
header("HTTP/1.0 400 Bad Request");
header("Status: 400 Bad Request");
exit;
}

Link to comment
https://forums.phpfreaks.com/topic/255570-session-not-working/
Share on other sites

Your codes for me. Just to be sure your passing the correct values insert this line:

echo '|'.$_SESSION["logged"].'|<br />';

Before the if statement to look at your variable. If  $_SESSION["logged"] is empty you'll just get a pair of lines. If it has a value that value will appear between the lines.

Link to comment
https://forums.phpfreaks.com/topic/255570-session-not-working/#findComment-1310367
Share on other sites

Assuming you're doing this

 

session_set_cookie_params(0, "/", ".weblyize.com", false); 

 

in the parent domain.  Then the session should work unless your subdomain is on a different box.  If it's on a separate box you'll have to figure out how you want to share the session files between them.  I'm sure you already know this but I'm just reiterating it to be thorough. 

Link to comment
https://forums.phpfreaks.com/topic/255570-session-not-working/#findComment-1310466
Share on other sites

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.