News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

How can i get $context['user']['id'] value?

Started by p44n, October 09, 2013, 10:47:10 AM

Previous topic - Next topic

p44n

How can i get $context['user']['id'] value?

I put require file for SSI.php first. And echo $context['user']['id']
It work on localhost. with $context['user']['id'] , $context['user']['is_logged'] ,  $context['user']['name']

But not work on Server.

I try all 2 day. But i cann't find why not work.

please help me. and thank alot for your help

sorry about my english . i am thai boy.

margarett

If it works on your localhost, it has to work in any other server, I guess :o

Do you get any error, either in the page you are viewing or in SMF/PHP log?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

p44n


echo $context['user']['is_logged']."---".$context['user']['name']."---".$context['user']['id']."---".$context['session_id'];


on above it print out =>
---บุคคลทั่วไป---0---

ps. บุคคลทั่วไป(Thai) it mean Guest(English)
ps. no error php log file. Sir.
ps. Different php version between localhost - Server? 5.xx - 5.yy

Thank you.

margarett

That is correct. If your user isn't logged in, it has no "is_logged", no ID and no session...

So you have to login to have values there :)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Arantor

You have to have SSI or one of the API files loaded first... they won't just magically be defined.
Holder of controversial views, all of which my own.


p44n

I have already login at hxxp:forum.domain.com [nonactive] and redirect to hxxp:www.domain.com [nonactive] i want to use $context['user']['id'] at hxxp:www.domain.com/index.php [nonactive] but not work on index.php

Thank you very much.  :)

ps. login by administrator id.
ps. yes i already require SSI.php first.


Arantor

Enable subdomain independent cookies in Admin > Configuration > Server Settings > Cookies and Sessions

You should log out and log back in again.
Holder of controversial views, all of which my own.


p44n

Thank you.
margarett
Arantor

i set enable subdomain. it work!!!!

This is very nice exp. This is knowledge. This is lesson for my life.




Advertisement: