GetSimple Support Forum
session_start for plugin? - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: session_start for plugin? (/showthread.php?tid=4638)



session_start for plugin? - whiteh0rs3 - 2013-04-16

I want to create my own simple plugin with their own CRUD administration backend. I tried to embed (php way) it in GS backend. It requires session_start() init before the plugin page backend loading.

My Question is:

1. Where is the right place to put session_start() based on my case
is it okay by using this? add_action('admin-pre-header', 'forms_init');
or is there any other way?

2. What is the session name for backend? I ask this cause i need to check whether the user has an authenticated admin session or not.

thanks..


RE: session_start for plugin? - mvlcek - 2013-04-16

(2013-04-16, 03:31:00)whiteh0rs3 Wrote: I want to create my own simple plugin with their own CRUD administration backend. I tried to embed (php way) it in GS backend. It requires session_start() init before the plugin page backend loading.

My Question is:

1. Where is the right place to put session_start() based on my case
is it okay by using this? add_action('admin-pre-header', 'forms_init');
or is there any other way?

2. What is the session name for backend? I ask this cause i need to check whether the user has an authenticated admin session or not.

thanks..

If you embed your administration backend as plugin in the getsimple backend, you will always be authenticated, when your plugin is called.

Otherwise (e.g. for AJAX requests) you can check with
Code:
$loggedIn = cookie_check();

GetSimple does not use sessions, but only cookies. If you use sessions yourself you might experience problems with other plugins. Try to not use sessions.
If you really need to use sessions, admin_pre_header would be the hook. Make sure to put your session_start in a try/catch, as another plugin might have called it before.


RE: session_start for plugin? - shawn_a - 2013-04-16

You can use session_name to use unique sessions


RE: session_start for plugin? - whiteh0rs3 - 2013-04-17

thanks mvlcek & shawn, i will give it a try..
although I'm still new to GS, I am very interested to learn more.