GetSimple Support Forum

Full Version: session_start for plugin?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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..
(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.
You can use session_name to use unique sessions
thanks mvlcek & shawn, i will give it a try..
although I'm still new to GS, I am very interested to learn more.