PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 25th, 2004, 01:28 PM
secks secks is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 secks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question PHP / ASP Session variable problem

Hi, my problem is this .. im creating a website in asp and a few pages that i have are in php .. the site requires you to login, so i am using asp session variables to store the login info .. however, when i try to access these session variables with php i cannot seem to find them .. can anyone help?
ty .. paul (noob)

Reply With Quote
  #2  
Old February 26th, 2004, 03:25 AM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 5
Send a message via MSN to Spongy
Why are you creating a site with php & asp? But, hey! I don't mind!
I've never used asp before but I think you can use cookies crossed between these two languages. I'm sure asp can handle cookies, so if you set them with asp, you can read them later on with php. Though it's a lot more easier to just keep it in one language.
If you never used cookies in php before, search php.net for $_SESSION. It's what you need to read a cookie. In combination with the explode() function you can easily store and read from your cookies.

Good luck!
__________________
Work to live, don't live to work

Reply With Quote
  #3  
Old February 27th, 2004, 12:31 PM
secks secks is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 secks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by Spongy
Why are you creating a site with php & asp? But, hey! I don't mind!
I've never used asp before but I think you can use cookies crossed between these two languages. I'm sure asp can handle cookies, so if you set them with asp, you can read them later on with php. Though it's a lot more easier to just keep it in one language.
If you never used cookies in php before, search php.net for $_SESSION. It's what you need to read a cookie. In combination with the explode() function you can easily store and read from your cookies.

Good luck!

Thanks, I don't really want to use cookies though. They're too insecure to be storing vital information in. Thanks for the input though

Reply With Quote
  #4  
Old February 27th, 2004, 06:29 PM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 5
Send a message via MSN to Spongy
What info do you need to store then? Sending a password through a session is just as insecure. Just set a variable that the user has logged in together with the username and/or userid and save it in a cookie. The rest of the info you just pull from the database! I'm not really sure what you mean with 'vital information'. Can you explain?

Reply With Quote
  #5  
Old September 26th, 2004, 10:46 PM
ronnywalder ronnywalder is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 ronnywalder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I also have this problem to solve

Quote:
Originally Posted by secks
Hi, my problem is this .. im creating a website in asp and a few pages that i have are in php .. the site requires you to login, so i am using asp session variables to store the login info .. however, when i try to access these session variables with php i cannot seem to find them .. can anyone help?
ty .. paul (noob)

Did you ever come up with a solution for this problem... I would love to know.

The best I could come up with was passing the variables in the url - totally unacceptable.

Reply With Quote
  #6  
Old September 27th, 2004, 06:19 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
If nothing else I'd love to know why you need both asp and php?

-KM-

Reply With Quote
  #7  
Old September 27th, 2004, 03:05 PM
peytons peytons is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 3 peytons User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This will not work.

Hi there,

I haven't read up on this, but knowing how sessions work, you should NOT be able to share session information (at least easily) between PHP and ASP.

Clarification:

Sessions work like this: The session variables are stored SERVER SIDE and the only thing that a client stores is the SESSION ID in a cookie or in the URL. In other words, if I'm logged in to your site, I get a unique session id on my computer that I send to the server every time I want a page from your site. Your server looks up my session id, and gets the variables associated with my session from the server itself.. username, user id, whatever.

Since session variables (except the id) are stored server side, that means that they are stored within the hypertext preprocessor program.. whether it be php or asp. Thus, there is no way to access the session variables from php with asp or vice-versa, UNLESS one of the programs provides some sort of interface. I'm not sure if one of them does or not, but I'm guessing no, since that would be somewhat insecure if any program on your computer could ask for session variables with a session id.

Bottom line is, you can't share session variables b/w php and asp because there's nowhere to get them.. they're stored INSIDE php or asp (ie, not on the client) and you can't get to them with the other program.


Potential Fix:

You could store an identifying session variable in a cookie on the client, but that kind of mitigates the usefulness (and security) of sessions

Another, potentially painful, solution is to make a wrapper in whichever language contains the session code. For example, if your sessions are set up in PHP, and you want ASP to be able to use them, make a PHP wrapper code which gets the session variables, then calls the ASP script from within the PHP script with the appropriate variables. This will probably be too slow for high-volume applications.

Last thing I can think of is to re-write everything in one language


Hope that helped!

-peyton

Reply With Quote
  #8  
Old September 27th, 2004, 03:27 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
PHP provides the set_session_handler function (its something like that) that allows you to specify your own functions for reading and writing session data. Via this you can store it in your own file format, use a database or whatever. However it is stored could then be accessed via ASP. Ie you could have a mysql database storing your session data, rewrite the session handler code for php to use it and then pull things out of there based on the session id that can just be passed to asp as a get argument.

-KM-

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP / ASP Session variable problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway