Jump to content

login session is not working until i hit any of ips page


RRK

Recommended Posts

Posted

Hi, I am new to IPS invision community. I have a project which using IPS invision forum. My project has codeigniter in backend and Angular in front end. What I am doing, I create an api in codeigniter that initiation the IPS session to check if user is logged in, Like below:

// \IPS\Session\Front::i(); // OR below I tried both
   \IPS\Dispatcher\External::i();

if(\IPS\Member::loggedIn()->member_id) {

   $res['status'] = 'true';
   $res['member_id'] = \IPS\Member::loggedIn()->member_id;
   $res['name'] = \IPS\Member::loggedIn()->name;

}else {                       
      $res['status'] = 'false';
   
}
return $res;

If it's return true then I use it on angular to display authenticated user pages. It's working fine when I login and use angular pages but once I close the browser without logging out and open it again, all angular pages display me I am logged out and when I click on any of IPS core page like login page or IPS index page it automatically logged me in and now if I open any of angular page it display me logged in. So until or unless I hit any of the forum code page it does not initiate session and my codeigniter api return false. I want that after opening the browser again as IPS session is already active so my angular pages should also display as login, why my codeigniter api keep returning false for session until or unless i hit any of ips core page.

Any help would be appriciated. Thanks in advance.

Posted

Double check your cookies to make sure they're not set to a subdirectory or something like that. If that is the issue, you can add constants in your constants.php to override the cookie defaults.

Posted

I have to say i have exactly the same issue.

My IPS forum is under Mysite.com/forums and the rest of the site is under mysite.com. Does this mean i should change my constants.php to change the cookie setting  and set :

define( 'COOKIE_DOMAIN', '.mysite.com' );
define( 'COOKIE_PATH', '/' );

?

Posted
21 hours ago, bfarber said:

Double check your cookies to make sure they're not set to a subdirectory or something like that. If that is the issue, you can add constants in your constants.php to override the cookie defaults.

Thanks for the answer,  when I am on angular page there is only one cookie set 'ips4_IPSSessionFront' and when I open the IPS page like mydomain.com/forum I got many cookies set like 'ips4_login_key', 'ips4_member_id', 'ips4_hasJS', 'ips4_ipsTimezone' etc. And once I open the forum page and open the angular page page again now all pages works fine as cookies are set now.
The cookies path for 'ps4_IPSSessionFront' is '/' and for all other cookies, it's '/forum' .

Can you please tell me what cookie variable I should use to override the default cookies path ?

Posted

@bfarberI set the cookie path on constants.php file under forum directory, now it seems to work for angular pages but now it break for forum pages. If i hit the forum page it asked me to login again and when i tried to login again it block me for 14 min. It happening each time. Each time i hit forum page and try to login it block me for 14 min and after 14 min, i able to login.
Any suggestion?

Posted
23 hours ago, jesuralem said:

I have to say i have exactly the same issue.

My IPS forum is under Mysite.com/forums and the rest of the site is under mysite.com. Does this mean i should change my constants.php to change the cookie setting  and set :

define( 'COOKIE_DOMAIN', '.mysite.com' );
define( 'COOKIE_PATH', '/' );

 ?

I set  define( 'COOKIE_PATH', '/' ); only and now it's working for angular pages but break for forum pages. you can test on your side if it also break for you. 

Posted

i did set both settings and it was a mess at first, same as you, but after clearling my browser cookies it is fine now.

So this can be done but i wouldn't do it on a live site. Fortunately i am not live yet.

Posted
14 hours ago, jesuralem said:

i did set both settings and it was a mess at first, same as you, but after clearling my browser cookies it is fine now.

So this can be done but i wouldn't do it on a live site. Fortunately i am not live yet.

Thanks, After setting domain cookie it seems working fine in preliminary testing.  Looking forward for testing result from my tester. 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...