User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,181 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,399 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 273 | Replies: 2
Reply
Join Date: May 2008
Posts: 1
Reputation: ellabean is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ellabean ellabean is offline Offline
Newbie Poster

Carrying Session via URL

  #1  
May 9th, 2008
Hi everyone.

I'm thiiis close to losing my wits over this. I'm working on carrying Session ID via the url (not secure, I know, but it's not meant to be) and I cannot for the life of me get this to work.

This is a hangman script (pre-written by someone else) that I need to carry the session id from the alphabet letters through the rest of the game and through both play again links. I think the trouble I'm having is the rest of my session ID links were neat ___.php links, rather than what these are, and I've tried every way I can think of to pass the SID without luck.

<?php
session_name ('YourVisitID');
ini_set('session.use_cookies', 0); // Don't use cookies.
session_start();

$Category = "Animals";
# list of words (phrases) to guess below, separated by new line
$list = "
Dog
Cat
Mouse
Lion
Bear"; 

    # if the current alphabet NOT found in the selected letters
    # at the link, add the currently selected letter
    else
    { $links .= "\n<A HREF=\"$self?letters=$alpha[$c]$letters&n=$n\">$alpha[$c]</A> "; }
  }
  # update the number of wrong choices
  # display a corresponding image
  $nwrong=$wrong; 
  if ($nwrong>6) $nwrong=6;
  echo "\n<p><BR>\n<IMG src=\"hangman_$nwrong.gif\" ALIGN=\"MIDDLE\" BORDER=0 WIDTH=100 HEIGHT=100 ALT=\"Wrong: $wrong out of $max\">\n";
  # if reached the max wrong trials
  if ($wrong >= $max)
  {
    $n++; # get the next word
    if ($n>(count($words)-1)) $n=0; # if the last, back to the first
    echo "<BR><BR><H1><font size=5>\n$word_line</font></H1>\n";
    echo "<p><BR><FONT color=\"red\"><BIG>SORRY, YOU ARE HANGED!!!</BIG></FONT><BR><BR>";
    if (strstr($word, " ")) $term="phrase"; else $term="word"; #check if phrase
    echo "The $term was \"<B>$word</B>\"<BR><BR>\n";
    echo "<A HREF=$self?n=$n".SID.">Play again.</A>\n\n";
  }
  
  # if not reached the max wrong trials 
  else
  {
    echo " &nbsp; # Wrong Guesses Left: <B>".($max-$wrong)."</B><BR>\n";
    echo "<H1><font size=5>\n$word_line</font></H1>\n";
    echo "<P><BR>Choose a letter:<BR><BR>\n";
    echo "$links\n";
  }
}

# if all the letters are matched ($done is true (1)) 
else
{
  $n++; # get next word
  if ($n>(count($words)-1)) $n=0; # if the last, back to the first
  echo "<BR><BR><H1><font size=5>\n$word_line</font></H1>\n";
  echo "<P><BR><BR><B>Congratulations!!! &nbsp;You win!!!</B><BR><BR><BR>\n";
  echo "<A HREF=$self?n=$n".SID.">Play again</A>\n\n";
}
?>

Any help is very much appreciated!
Last edited by ellabean : May 9th, 2008 at 9:31 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 442
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 65
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Carrying Session via URL

  #2  
May 10th, 2008
Any particular reason why you're disabling cookie functionality, that would solve your problem right there.
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
Reply With Quote  
Join Date: Sep 2005
Posts: 611
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 38
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Re: Carrying Session via URL

  #3  
May 10th, 2008
ellabean, I think in PHP.ini there is a directive that tell's PHP whether appending sessions in the URL is allowed or not. It may have been added later, or the default changed in later PHP versions. I'm just recalling from reading the php session docs, so take a look, I might be wrong...
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

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

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:46 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC