Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.