Closed Thread Icon

Topic awaiting preservation: Need more help... This time sessions... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=24517" title="Pages that link to Topic awaiting preservation: Need more help...  This time sessions... (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Need more help...  This time sessions... <span class="small">(Page 1 of 1)</span>\

 
Ensellitis
Bipolar (III) Inmate

From: New York, USA
Insane since: Feb 2002

posted posted 12-28-2004 13:03

I managed to get a session to kinda start...

code:
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
?>



Then in my shoutbox, I got:

code:
$name = $_POST['name'];
$_SESSION['name'] = $name;



And the saved info prints out here:

code:
<p class="chat">Name<br /><input type="text" name="name" value="<? echo $_SESSION['name']; ?>" id="name" /></p>



As soon as you post the message, the info stays... But as soon as you go to another section, BAM it's gone again...

I've got these lines on every single page... Anyone know what is up? If I didn't give enough info, let me know. I will even give someone all of the code if they can help me find the problem...



(Edited by Ensellitis on 12-28-2004 13:09)

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 12-28-2004 13:40

well, if you got these lines on every single page, you are reseting it $_SESSION['name'] to NULL everytime you user does not post.

You'll need to put an if (isset($_POST['name'])) {} around setting your session variable.
And why don't you just use $_SESSION['name'] = $_POST['name'].

Also, please not that you have just opened your users to scripting attacks. You really should call at least htmlentities() on your post variables before printing them again.

so long,

->Tyberius Prime

Ensellitis
Bipolar (III) Inmate

From: New York, USA
Insane since: Feb 2002

posted posted 12-28-2004 22:05

Alright, I did that and now it works like a charm. Thanks alot, Tyberius.

« BackwardsOnwards »

Show Forum Drop Down Menu