Joomla! Discussion Forums



It is currently Thu Nov 26, 2009 10:57 pm (All times are UTC )

 




Post new topic Reply to topic  [ 15 posts ] 
Author Message
Posted: Thu Feb 28, 2008 10:58 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Feb 22, 2008 3:21 pm
Posts: 12
i need to get the current session username in my wapped php page! for do an experiment and verify the code working i write this code
Code:
global $my;
$username= $my->username;
print "my username is $username"


but the output is

Code:
my username is


how do i do? what's i wrong? help me plz


Top
  E-mail  
 
Posted: Thu Feb 28, 2008 11:08 am 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Thu Aug 18, 2005 10:41 am
Posts: 15098
Moderator note; adjusted all caps subject, moving from General > 1.0 Development

_________________
Regards Robin


Top
   
 
Posted: Thu Feb 28, 2008 2:02 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Feb 22, 2008 3:21 pm
Posts: 12
sorry :-[


Top
  E-mail  
 
Posted: Thu Feb 28, 2008 2:31 pm 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Thu Aug 18, 2005 10:41 am
Posts: 15098
No worries.

Try changing the "print..." to something like "echo $username".

If that works, you need to add that sentence to it, "my username is", but be sure to put that out of the php tags.

_________________
Regards Robin


Top
   
 
Posted: Fri Feb 29, 2008 7:27 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Feb 22, 2008 3:21 pm
Posts: 12
:'( nothing output, error on line.... sniff i cryyyyyyyyyyyyy.... ??? :-\


Top
  E-mail  
 
Posted: Fri Feb 29, 2008 7:39 am 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Thu Aug 18, 2005 10:41 am
Posts: 15098
Any "expert" on this? As I'm no true coder either? ;)

_________________
Regards Robin


Top
   
 
Posted: Fri Feb 29, 2008 10:58 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Feb 22, 2008 3:21 pm
Posts: 12
there isn't any persons? heeeeeeeelp


Top
  E-mail  
 
Posted: Tue Mar 04, 2008 7:44 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Feb 22, 2008 3:21 pm
Posts: 12
Thx at all for all replies >:( >:( -.- -.-'


Top
  E-mail  
 
Posted: Mon Apr 07, 2008 7:37 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Thu Jan 31, 2008 10:15 am
Posts: 9
Mind to ask, where did you put these piece of code?
*.php or *.html.php?


Top
  E-mail  
 
Posted: Mon Apr 07, 2008 8:29 am 
User avatar
Joomla! Champion
Joomla! Champion
Offline

Joined: Fri Sep 09, 2005 2:13 pm
Posts: 6771
Location: The Netherlands
On the top of the page start with:

For the user id:

Code:
global $my;

echo $my->id;


OR

For the username:

Code:
global $my;

echo $my->username;


I hope this works

_________________
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards


Top
  E-mail  
 
Posted: Mon Apr 07, 2008 8:46 am 
User avatar
Joomla! Champion
Joomla! Champion
Offline

Joined: Fri Sep 09, 2005 2:13 pm
Posts: 6771
Location: The Netherlands
And if you want to echo a sentence:

Code:
echo "My username is ". $my->username;


What you're doing is PHP and HTML without any structure, this won't work mostly

_________________
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards


Top
  E-mail  
 
Posted: Wed Apr 16, 2008 11:31 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Wed Apr 16, 2008 11:12 pm
Posts: 2
Hi. I've also been trying to do this but can't get it working. I want to use the joomla user name/password/id on a seperate non-joomla php page.

As a test

1. I login to joomla from the index.php
2. I go to be address bar and enter the location of the test php page to display the id
3. It doesn't work.

My tests php page has this
Code:
<?php

global $my;
$my->id;


echo "$my->id";
?>


It outputs a blank page. But if i put echo "$my->id"; in a file mod_login.php it will display the id perfectly. What does the test page need to be able to grab this?

Thanks.


Top
  E-mail  
 
Posted: Thu Apr 17, 2008 3:34 am 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Wed Apr 16, 2008 11:12 pm
Posts: 2
Ok this seemed to make it work.

Code:
define( '_VALID_MOS', 1 );

include_once( 'globals.php' );
require_once( 'configuration.php' );
require_once( 'includes/joomla.php' );
$option="test";
$mainframe = new mosMainFrame( $database, $option, '.' );
$mainframe->initSession();

$my = $mainframe->getUser();

echo $my->username;


Top
  E-mail  
 
Posted: Thu Sep 11, 2008 9:43 am 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Wed Sep 10, 2008 3:49 am
Posts: 1
put this code in your joomla folder (the parent folder) .

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?



define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

//JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;

/**
* CREATE THE APPLICATION
*
* NOTE :
*/
$mainframe =& JFactory::getApplication('site');



$user =& JFactory::getUser();

echo $user->username;

echo "<p>Your name is {$user->name}, your email is {$user->email}, and your username is {$user->username}</p>";
  echo "<p>Your usertype is {$user->usertype} which has a group id of {$user->gid}.</p>";
   
   ?>

</body>
</html>


log in as a member in joomla. open a new browser and run this code from the new browser. you may edit this code as you wish to suit your application/system/script.

i tried, and it was a success!

-- in this world, there are 10 kinds of people, the one who knows binary, and does not --

_________________
-- in this world, the are only 10 type of people. The one who knows binary and does not --


Top
  E-mail  
 
Posted: Tue Oct 13, 2009 11:22 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Oct 10, 2009 9:01 am
Posts: 6
hi thanks for this post.

What about updating the Joomla session database? (jos_session)?
How can I update it so that from my application (outside of joomla) but the same domain., when the users switch back to my joomla site, he is still login.

considering that I have set session timeout to default which is 15 minutes.

can you help me with this?


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

Quick reply

 



Who is online

Users browsing this forum: tekknokrat and 7 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group