Joomla! Discussion Forums



It is currently Fri Nov 27, 2009 1:45 am (All times are UTC )

 




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Session variables
Posted: Thu Dec 28, 2006 3:08 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Tue Sep 19, 2006 4:22 am
Posts: 73
Location: Michigan
What are some of the session variables like user name and if a person is logged in or not? I have been looking around for this information but am unable to find it.

Thanks,

-T

_________________
-How important does a person have to be before they are considered assassinated instead of just murdered?
-He's not carnival personnelle!!!


Top
  E-mail  
 
 Post subject: Re: Session variables
Posted: Thu Dec 28, 2006 3:11 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Fri Aug 19, 2005 12:37 am
Posts: 945
Location: Washington, DC / NoVA
The information you're looking for is in the global object $my. Pull it into whatever function you're in and do a print_r on it to see all of the information for the currently logged in user.

_________________
Joseph L. LeBlanc: http://www.jlleblanc.com
Frontend components start here: /components/com_[name]/[name].php
Backend components start here: /administrator/components/com_[name]/admin.[name].php


Top
   
 
 Post subject: Re: Session variables
Posted: Thu Dec 28, 2006 3:50 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Tue Sep 19, 2006 4:22 am
Posts: 73
Location: Michigan
I am embarrassed to say this but can you lend a brother some code that will show this????


Thanks again fur your help

_________________
-How important does a person have to be before they are considered assassinated instead of just murdered?
-He's not carnival personnelle!!!


Top
  E-mail  
 
 Post subject: Re: Session variables
Posted: Thu Dec 28, 2006 4:01 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Fri Aug 19, 2005 12:37 am
Posts: 945
Location: Washington, DC / NoVA
If you're in the middle of a component, do this:

Code:

print_r($my);



If you're in a function, you'll need to do this

Code:

function yourCustomFunction()
{
  global $my;

  print_r($my);
}



That should do it.

_________________
Joseph L. LeBlanc: http://www.jlleblanc.com
Frontend components start here: /components/com_[name]/[name].php
Backend components start here: /administrator/components/com_[name]/admin.[name].php


Top
   
 
 Post subject: Re: Session variables
Posted: Thu Dec 28, 2006 8:09 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Tue Sep 19, 2006 4:22 am
Posts: 73
Location: Michigan
U rock

_________________
-How important does a person have to be before they are considered assassinated instead of just murdered?
-He's not carnival personnelle!!!


Top
  E-mail  
 
 Post subject: Re: Session variables
Posted: Sun Mar 11, 2007 3:29 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Feb 05, 2007 5:53 am
Posts: 10
Hi, 

This is great.  However, the $my variables actually come from the jos_users table - not the jos_sessions table.
$my->gid is not really the session id.

How do I get the real session id that is registered in the jos_sessions table?

Best regards,

Adrian


Top
   
 
 Post subject: Re: Session variables
Posted: Sun Mar 11, 2007 8:32 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Fri Aug 19, 2005 12:37 am
Posts: 945
Location: Washington, DC / NoVA
You should be able to get this out of $mainframe->_session.

_________________
Joseph L. LeBlanc: http://www.jlleblanc.com
Frontend components start here: /components/com_[name]/[name].php
Backend components start here: /administrator/components/com_[name]/admin.[name].php


Top
   
 
 Post subject: Re: Session variables
Posted: Tue Jun 24, 2008 5:02 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Feb 03, 2007 3:02 am
Posts: 7
Location: Peru, ME USA
I'm working on a similar issue. I attached some code to the bottom of index.php to save the username as a Session variable.

$_SESSION['user'] = $my->username;

This all seems to work fine on my Windows XP Pro test server, but when I uploaded the exact page to my web host it seems to lose the $_SESSION Variable entirely.

I'm testing it using a separate 'Session Test' page that displays all the $_SESSION variables.

Any ideas on what could be different that would cause this?

Thanks,
Chas


Top
   
 
 Post subject: Re: Session variables
Posted: Fri Apr 03, 2009 4:33 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Thu Apr 02, 2009 9:44 am
Posts: 14
To get session id use this: $user->get['id'];
this will work in your page.


Top
  E-mail  
 
 Post subject: Re: Session variables
Posted: Thu Apr 09, 2009 11:01 pm 
User avatar
Joomla! Explorer
Joomla! Explorer
Offline

Joined: Wed Nov 16, 2005 2:02 am
Posts: 459
Location: Breklum - Nordfriesland
bishnu maharjan wrote:
To get session id use this: $user->get['id'];
That will give you the user id, not the session id. You'll find the session id in the $_SESSION array.

Regards,
Niels


Top
   
 
 Post subject: Re: Session variables
Posted: Thu Oct 08, 2009 11:30 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Sep 11, 2009 6:21 am
Posts: 7
jlleblanc wrote:
If you're in the middle of a component, do this:

Code:

print_r($my);



If you're in a function, you'll need to do this

Code:

function yourCustomFunction()
{
  global $my;

  print_r($my);
}



That should do it.



is it work fine in iframe, because i run this code in iframe but can't see any result.


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group