CodeIgniter Forums
how to share SESSION with WP - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: how to share SESSION with WP (/showthread.php?tid=70328)



how to share SESSION with WP - ardavan - 03-26-2018

Hi, everybody,

I'm working on a microsite in CI and this microsite will generate some session data.
on the same Host & domain, we have another website with is WordPress.

I would like to make use of CI session generate in Wordpress website. Confused

example:
set on CI
PHP Code:
// http://www.website.com/cp/
$this->session->set_userdata('some_name''some_value'); 

call it on WP header.php
PHP Code:
// http://www.website.com/ 
$_SESSION['some_name']; //some_value 

Is it possible to do so?  Huh
Please show me the correct approach.  Smile

Thanks in advance


RE: use CI session on microsite like wordpress - InsiteFX - 03-26-2018

You would need to edit and change every WordPress file that used sessions

So personally I would not recommend it at all.


RE: use CI session on microsite like wordpress - ardavan - 03-26-2018

isn't possible to just check that session in header.php in WordPress?

so if i must edut every WP file that used session, how can be possible? could you show some demo code?


RE: use CI session on microsite like wordpress - visualsol - 03-26-2018

Hi Ardavan,
I've done the opposite way, I've utilized the Wordpress login and sessions, and then referenced the sessions on the CI side.
It works, but it pulls in more of the wordpress side functionality than I would like, and you have to be careful when Wordpress major updates happen. If that is of interest to you, let me know.
Bob

(03-26-2018, 02:19 AM)ardavan Wrote: Hi, everybody,

I'm working on a microsite in CI and this microsite will generate some session data.
on the same Host & domain, we have another website with is WordPress.

I would like to make use of CI session generate in Wordpress website. Confused

Is it possible to do so?  Huh
Please show me the correct approach.  Smile

Thanks in advance



RE: use CI session on microsite like wordpress - ardavan - 03-26-2018

Hey Bob, thanks for your reply,
So if you have done the opposite way, that means I can do another way around.
basically, my microsite is a user management for the WordPress website and will generate some session that can use in the WordPress(of course there will be some hard coding in the WordPress header.php).

My question is if the session works on a domain, so I can get the session in a plain PHP code right?

what I am thinking is to generate a session in plain PHP (in the microsite - CI) and then call that session in plain PHP (in the WordPress - header.php)

set on CI
PHP Code:
// http://www.website.com/cp/
$this->session->set_userdata('some_name''some_value'); 

call it on WP header.php
PHP Code:
// http://www.website.com/ 
$_SESSION['some_name']; //some_value 

how can I do this? I mean that is my first time and idk how to make this to happen.

any idea?

(03-26-2018, 08:38 PM)visualsol Wrote: Hi Ardavan,
I've done the opposite way, I've utilized the Wordpress login and sessions and then referenced the sessions on the CI side.
It works, but it pulls in more of the WordPress side functionality than I would like, and you have to be careful when Wordpress major updates happen.  If that is of interest to you, let me know.
Bob

(03-26-2018, 02:19 AM)ardavan Wrote: Hi, everybody,

I'm working on a microsite in CI and this microsite will generate some session data.
on the same Host & domain, we have another website with is WordPress.

I would like to make use of CI session generate in Wordpress website. Confused

Is it possible to do so?  Huh
Please show me the correct approach.  Smile

Thanks in advance