1

I want to provide admin links from the main site for clients, however within the admin URL there is the session parameter.

Is there a way to output the admin url path that includes the dynamic session parameter? Alternatively i can switch the session ID off in security settings but thats a second preference.

Any ideas?

2 Answers 2

3

It is possible, but the mechanism for generating session IDs changed for EE 2.6, so if you want to retain compatibility with 2.5 and under (as I did) you need to add in a quick version_compare check.

Here's the snippet that I'm using with Missing Link.

$sess_type = $this->EE->config->item('admin_session_type');
$session_id = ($sess_type == 'c') ? '0' : $this->userdata['session_id'];

if (version_compare(APP_VER, '2.6.0', '>=') AND $sess_type == 'cs')
{
 $session_id = $this->userdata['fingerprint'];
} 

That should give you an accurate $session_id no matter which EE version or session type is in use.

I'd strongly recommend creating a plugin for this, if you haven't already, as PHP in templates is a Bad Idea.

1
  • $this->userdata has to point to $this->EE->session->userdata (or the newer ee() funtion )
    – GDmac
    Sep 20, 2013 at 9:00
0

No, there's no native way to output the admin URL path with a dynamic session preset. You will have to have cookies turned on and include S=0& right after the ? in URL.

1
  • With cp-security set to both cookies and session-id, when you leave out S=value or when you set S=0 in the url, you get thrown back to the login page :-(
    – GDmac
    Sep 20, 2013 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.