NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page new to PHP ... coming from ASP

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-17-2006, 07:11 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
timmaay's Avatar
Join Date: Dec 2005
Location: up north
Posts: 577
timmaay is just really nicetimmaay is just really nicetimmaay is just really nicetimmaay is just really nicetimmaay is just really nice
 


Child Abuse

new to PHP ... coming from ASP


well i am new to PHP and have a quick question

in ASP you have a global.asa which you can set and reference a session var.

for example:

sub session_onstart()
session("ip") = request.servervariables("REMOTE_ADDR")
end sub

now whenever someone hits any page on my site i have a session("ip") variable i can reference.
????: NamePros.com http://www.namepros.com/programming/270389-new-to-php-coming-from-asp.html

I need to do this same thing in php.
(ie) i only want to load this variable once from whatever page user enters on and be able to reference it on any subsequent pages.

keep in mind: I am a novice at php

thanks in advance

Tim
__________________
Wisconsin Apartment Listings
timmaay is offline  
Old 12-17-2006, 07:15 PM   #2 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
PHP Code:
session_start();
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; 
So anywhere within PHP, you could do echo $_SESSION['ip']; and it would have the IP stored in it. (I'm not sure what the sub stuff is, so I don't know if this does everything you asked. :x)
Dan is offline  
Old 12-17-2006, 07:15 PM   #3 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,552
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
It ain't difficult
PHP Code:
<?php
session_start
();
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
????: NamePros.com http://www.namepros.com/showthread.php?t=270389
?>
__________________
NameNewsletter.com - free lists of available domain names
ZoneFiles.net (beta) - ccTLD and gTLD droplists
sdsinc is offline  
Old 12-17-2006, 07:20 PM THREAD STARTER               #4 (permalink)
NamePros Regular
 
timmaay's Avatar
Join Date: Dec 2005
Location: up north
Posts: 577
timmaay is just really nicetimmaay is just really nicetimmaay is just really nicetimmaay is just really nicetimmaay is just really nice
 


Child Abuse
basically asp has a special file called global.asa
this file has a few functions in it and one of them is
Sub session_onstart()

this function runs whenever someone first comes to the site

ex)
person A google searches and clicks on a link to mypageA.asp
then goes to mypageB.asp ...
before he hits mypageA.asp -> session_onstart() function runs.
when he then goes to mypageB.asp session_onstart() function doesn't run because it was invoked before mypageA.asp already.

basically it makes it so i don't need to include a file on top of every page
__________________
Wisconsin Apartment Listings
timmaay is offline  
Old 12-17-2006, 07:33 PM   #5 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Well you need to have session_start(); on every page (that you need the variables), but the variables will still be saved.
Dan is offline  
Old 01-03-2007, 12:54 PM   #6 (permalink)
Account Closed
 
shahzad11's Avatar
Join Date: Nov 2006
Location: Lahore
Posts: 297
shahzad11 is on a distinguished road
 



Originally Posted by sdsinc
It ain't difficult
PHP Code:
<?php
????: NamePros.com http://www.namepros.com/showthread.php?t=270389
session_start
();
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
?>
thanks very much because i was having a great problem and you solved it
shahzad11 is offline  
Old 01-03-2007, 05:19 PM   #7 (permalink)
NamePros Regular
 
Noobie's Avatar
Join Date: Feb 2006
Location: Montreal, Quebec, Canada
Posts: 324
Noobie is on a distinguished road
 



Glad you switched
__________________
Goldkey.com is a scam
What's your BMI? | Timestamp Generator
Noobie is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:51 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger