Checking variables

They have: 71 posts

Joined: Aug 2001

hey guys, i am working with sessions and i need to check which variables exist within the session and print the ones that do exist to the users page. how can i do this?

detox's picture

They have: 571 posts

Joined: Feb 2001

I assume this is ASP?

Just go through the session variables with an if then else loop... When you have a match, send it to the screen.

to speed it up you could make a custom dictionary object and then roll through that checking which variables are filled. When you have the results simply response.write them to the page.

a little more info would be nice....

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

For some reason, ASP popped into my mind as well.

If you need PHP code:

<?php
foreach ($HTTP_SESSION_VARS as $key=>$value) {
    echo \
"$key = $value\n\";
}
?>

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 71 posts

Joined: Aug 2001

oops sorry, PHP. Mark's code worked okay I just adjusted it a tiny bit thanks guys Smiling

detox's picture

They have: 571 posts

Joined: Feb 2001

Just to let everyone know I am beginning to feel like a dinosaur being more proficient in ASP and ASP.Net than PHP!!!!!!

sob sob, sympathy please!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I can program ASP... But the last time I programmed ASP for an employer was over a year ago. I haven't had access to a server, so I haven't used it since. Possitive and negative effect: I've strengthened my PHP skills, but my knowledge of ASP is wearing thin.

Vive le Open Source! Laughing out loud

Mark Hensler
If there is no answer on Google, then there is no question.

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

detox, I feel your pain Smiling

I'm also in the ASP camp, I just don't have the time right know to start messing with PHP in depth Sad

detox's picture

They have: 571 posts

Joined: Feb 2001

Exactly,
I am busy getting lost in .Net right now, so I only have a little bit of time to get the rudimentaries of PHP.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.