Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Basic Sessions?

session

  • Please log in to reply
1 reply to this topic

#1 phpforfun

phpforfun

    Speaks fluent binary

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1056 posts

Posted 21 April 2008 - 08:31 AM

Pretty basic, but for some reason im stuck. I cant get sessions to run.. I dont think. Or maybe I have a problem getting the set information.

Look at this..

http://analyzethathost.com/session.php

the EXACT code for that is this.

<?
session_start();
$username = $_SESSION['username'];
if(isset($username)){
Echo $username;
} Else {
if(isset($_GET['do'])){
session_register("username", JohnDoe);
Echo 'session started! <a href="?">Click here to go home and view the name your session was started with</a>';
} Else {
Echo '<a href="?do=yes">click here to start session</a>';
}
}
?>


I was told that is the correct code, and its the code I pretty much cut and pasted from the other music site I had a while back..

any ideas? Does it work for you guys?
  • 0

#2 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 21 April 2008 - 09:20 AM

PHP: session_register - Manual

If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.


  • 0





Also tagged with one or more of these keywords: session

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download