1) session_start() is not really required on any other pages beside the
index.php because session_register take care of that for you.

2) It should work when you try session_register() on the index.php, use a
makeup name, like session_register("user") then assign the data to it, like
$user[username] = "whatever" & $user['password'] = "passwhatever".  This is
a simplier way and it does work.

"Petre" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi
> I am still battling alot with understanding how sessions work (don't
> work in my case).
>
> Firstly: I am trying to find a reliable method for coding with sessions
> that will work on basically any server and any browser; meaning no
> cookies and passing the SID to all url's manually.
> My app has the following ( amongst others)
> index.php = login page with form and 2 fields (username / password),
> session_start()
> On the action page, I session_start() again, and then
> session_register("username","password") and I don't need to give them
> values as the form fields are called that and PHP generates them for me
> (register_globals = on).
> This works great, on ALL subsequent pages in the app, I can simply call
> $username and $password, and it works.
>
> BUT, my app has alot of iterations, and now I'm battling to understand
> how to change these session variables "on the fly" in a sensible manner;
> in particular when it comes to forms that "generate" their own variables
> on submit.
>
> It seems like my problem comes in that I can only set a session variable
> once it "exists" , ie, on the action page, and then also, that the app
> goes "backwards" allowing you to change your options, yet, when yuou do,
> the variables does not contain the new variables.
>
> The fact that the app also doesn't have a specific "end" means I also
> don't know where to place the session_destroy()...
>
> I have made 4 small pages to illustrate :
>
> index.php
> --------------------------------------------------------------------------
------------------------------------------
> <?php
> session_start();
> ?>
> <form action="page2.php?<?=SID?>" method="POST"
> enctype="multipart/form-data">
>   <table>
>   <tr>
>     <td>Username  </td>
>     <td><input type="text" name="username">  </td>
>   </tr>
>   <tr>
>     <td>Password  </td>
>     <td><input type="text" name="password">  </td>
>   </tr>
>   <tr>
>     <td>  </td>
>     <td><input type="submit" name="submit"></td>
>   </tr>
> </table>
> </form>
> --------------------------------------------------------------------------
------------------------------------------
> page2.php
> --------------------------------------------------------------------------
------------------------------------------
> <?php
>   session_start();
>   session_register("username","password");
> ?>
> This is username: <?=$username?><br>
> This is password: <?=$password?><br>
> <form action="page3.php?<?=SID?>" method="POST"
> enctype="multipart/form-data">
>   <table>
>   <tr>
>     <td>First Variable</td>
>     <td><input type="text" name="first">  </td>
>   </tr>
>   <tr>
>     <td>Second Variable</td>
>     <td><input type="text" name="second">  </td>
>   </tr>
>   <tr>
>     <td></td>
>     <td><input type="submit" name="submit"></td>
>   </tr>
> </table>
> </form>
> --------------------------------------------------------------------------
------------------------------------------
> page3.php
> --------------------------------------------------------------------------
------------------------------------------
> <?php
>   session_start();
>   session_register("first","second");
> ?>
> This is username: <?=$username?><br>
> This is password: <?=$password?><br>
> This is first variable: <?=$first?><br>
> This is second variable: <?=$second?><br>
> <a href="page2.php?<?=SID?>">To Page 2</a><br>
> <a href="page4.php?<?=SID?>">To Page 4</a><br>
> --------------------------------------------------------------------------
------------------------------------------
> page4.php
> --------------------------------------------------------------------------
------------------------------------------
> <?php
>   session_start();
> ?>
> This is username: <?=$username?><br>
> This is password: <?=$password?><br>
> This is first variable: <?=$first?><br>
> This is second variable: <?=$second?><br>
> <a href="page3.php?<?=SID?>">To Page 3</a>
> --------------------------------------------------------------------------
------------------------------------------
>
> Also, not sure if it is browser related, but on mine, I sometimes get 2x
> SESSIONID=xxxxxxxxxxxx added to the end of the URL, even though I
> clearly put it in once only...
>
> Am I missing the point here?
> Plz help to make things clearer to me...
> The only way I can get above scanario to work is to add the variable
> manually to all the url's as I've been coding all along.
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to