Find Host IP address

  • wpas
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 12, 2010
  • Posts: 214
  • Loc: Canada
  • Status: Offline

Post July 26th, 2011, 2:58 pm

Thanks for your response

Can I still use my if(isset()) function idea.
Not a great programmer so would appreciate how to do this properly

Thanks
http://www.schembrionics.com
The Ultimate Solutions Center
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 26th, 2011, 2:58 pm

  • may
  • Proficient
  • Proficient
  • User avatar
  • Joined: Dec 25, 2004
  • Posts: 328
  • Loc: Holland [NL]
  • Status: Offline

Post July 27th, 2011, 12:58 am

Hi Wpas,

I think you isset function will work.
Logic : If var is not set (read is var defined?), then define the variable using the following value. Else do nothing because the var is allready there.

PHP Code: [ Select ]
session_start();
if(!isset($_SESSION{'HTTP_REFERER'})){
       $_SESSION{'HTTP_REFERER'} = $_SERVER{'HTTP_REFERER'};
}
 
  1. session_start();
  2. if(!isset($_SESSION{'HTTP_REFERER'})){
  3.        $_SESSION{'HTTP_REFERER'} = $_SERVER{'HTTP_REFERER'};
  4. }
  5.  


rgrds,
1 + 1 = 10 + 1 = 11 + 11 = 110
  • wpas
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 12, 2010
  • Posts: 214
  • Loc: Canada
  • Status: Offline

Post July 28th, 2011, 11:43 am

Hi May

When I first tried it, it did not work.

As I had mentioned before I have a joomla website and it has some issues with standard PHP sessions as it has its own session manager.

However, when I replaced !isset with just !, it worked perfectly.

Thank you for your help
http://www.schembrionics.com
The Ultimate Solutions Center
  • may
  • Proficient
  • Proficient
  • User avatar
  • Joined: Dec 25, 2004
  • Posts: 328
  • Loc: Holland [NL]
  • Status: Offline

Post July 28th, 2011, 11:25 pm

I have seen allot in my days, but your last comment doesnt make any sense.

!$_SESSION{'something'} might trigger and PHP NOTICE message if the var $_SESSION{'something'} isnt defined, this is why you want to test it with isset first.
1 + 1 = 10 + 1 = 11 + 11 = 110
  • wpas
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 12, 2010
  • Posts: 214
  • Loc: Canada
  • Status: Offline

Post July 29th, 2011, 8:38 pm

Hi May

As mentioned previously, my website is a Joomla CMS site.

Joomla uses their own session management so when you use standard php session it won't work. This is why I had to use the joomla session management.

As everything in Joomla is powered by it's own internal framework, I cannot use pure PHP for something like sessions, as Joomla overwrites old session variables when it initializes it's own internal session management code. Joomla has its own class for session handling that is only applicable inside its system.

For a PHP sesssion we set as:

$_SESSION['name']

For Joomla, we actually have a function to set the session;

$session->set('name', $data)

And to get the session we have another function:

$session->get('name', $data)

To go back to your PHP isset function then, you had to test for the presence of the session:

if(!isset($_SESSION{'name'})){

For joomla, since it is a function, the equivalent would be

If(!$session->get('name', $data)){

Hopefully you see why I changed !isset() to just ! because a function is already used to get the session.
http://www.schembrionics.com
The Ultimate Solutions Center
  • may
  • Proficient
  • Proficient
  • User avatar
  • Joined: Dec 25, 2004
  • Posts: 328
  • Loc: Holland [NL]
  • Status: Offline

Post July 30th, 2011, 12:27 pm

Just glad it works.

I understand that most MVC frameworks will unregister the globals for obvious security related reasons.

I dont now the Joomla internals, and depending on the return values the object method supports your approach might or might not be the right one. Im just glad it worked out for you :)

Rgrds,
1 + 1 = 10 + 1 = 11 + 11 = 110

Post Information

  • Total Posts in this topic: 36 posts
  • Users browsing this forum: No registered users and 148 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.