ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Retrieving member_id using PHP for non-control panel users

August 03, 2012 6:16am

Subscribe [2]
  • #1 / Aug 03, 2012 6:16am

    eyekiller

    5 posts

    Hi all

    I have a module that requires a {member_id} before that variable is parsed (as the modules are parsed beforehand)... so I’ve used PHP, but I’ve found that the Session class only works for hose users who have logged in with the control panel…

    My users log in using a members login form, and I need to retrieve their {member_id} from the cookie so I can pass to this form…  all attempts have failed 😕

    any help with this would be greatly appreciated…


    many thanks in advance

  • #2 / Aug 03, 2012 6:48am

    Mike Bean

    14 posts

    Have you tried using logged_in_member_id instead of member_id?

  • #3 / Aug 03, 2012 7:07am

    eyekiller

    5 posts

    Hi Mike

    Yeah..  I tried that first.  The module I’m using (after a bit of debugging) was being passed the literal string “{logged_in_member_id}”...  also, if I use

    <?php echo $this->EE->session->userdata('logged_in_member_id'); ?>

    it returns a blank value

  • #4 / Aug 03, 2012 7:10am

    eyekiller

    5 posts

    if I look at my cookies I can see an exp_sessionid, which I understand, is the same id used in the control panel if I were to log in there…  is there any way of parsing that ID and retrieving the data without tearing strips out of the code (something I’d like to avoid)

  • #5 / Aug 03, 2012 7:43am

    eyekiller

    5 posts

    Nevermind… user error 😕

  • #6 / Aug 03, 2012 11:06am

    Lisa Wess

    20502 posts

    Hi, eyekiller - I just want to confirm that you did get this working?

    Thank you!

  • #7 / Aug 03, 2012 11:34am

    eyekiller

    5 posts

    Hey Lisa

    Yes, I got this working… the

    <?php echo $this->EE->session->userdata('member_id'); ?>

    worked.

  • #8 / Aug 03, 2012 12:06pm

    Lisa Wess

    20502 posts

    Awesome, very glad to hear it! If anything else comes up, please let us know, and have a wonderful weekend!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases