Re: [PHP] Passing variables between pages



On Fri, Sep 19, 2008 at 10:54 AM, Jason Pruim <japruim@xxxxxxxxxx> wrote:

Hi everyone,

Stupid question of the week...

A array variable is not being passed between 2 pages. Are my options:

#1. Use sessions?

#2. Use cookies?

#3. Use a hidden form to pass the variable's around?

Here's some context... I am working on a timecard system where they are
presented the main page, where they login they are brought to a screen where
they need to clock in/out. It all starts working great, but when they clock
in/out it loses the variable that says they are logged in so it tries to
re-authenticate them which doesn't work since the username/password are no
longer in the $_POST array...

I can provide code if needed, but I think it's just a logic problem on my
end :)

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


If I am understanding correctly...


It sounds like you need to pass that variable in your $_SESSION's. You'll
want to carry that $_SESSION you established upon login over to the page
that handles clicking in and out.

From what I gather here, this is what I'd do.

Main page, login, $_SESSION gets set.

Click on check in, page to check in comes up, does a session_start(), and
then you check for that $_SESSION variable to make sure its still them.
Check on each page for that session var, if its gone, put 'em back to the
log in page.

Make sense?

--
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


Relevant Pages

  • Re: Please! Doesnt anyone know a better way to do this?
    ... account, they need to automatically be directed to the page to enter data ... session variable on the Account page. ... I assume here that you're checking a database when the user attempts to ... When a new user attempts to login or clicks to register, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: nooB PhP login using MySQL
    ... This PC has MySQL and IIS configured and running. ... how do I prevent users from bypassing the login? ... create a random string and store in session on server, ... euphemism for md5) but now that there are secure ways, ...
    (comp.lang.php)
  • Re: nooB PhP login using MySQL
    ... This PC has MySQL and IIS configured and running. ... how do I prevent users from bypassing the login? ... create a random string and store in session on server, ... euphemism for md5) but now that there are secure ways, ...
    (comp.lang.php)
  • Re: why a session-based program behaves different on different computers
    ... But if you lose the session you lose ... now, pray-tell, HOW IS THE DATA LOST? ... IF THERE IS NO LOGIN, HOW DO YOU DETERMINE WHICH ROW IT IS? ... let's stick to the architecture for a moment then. ...
    (comp.lang.php)
  • Help/Advice/Example Code Needed for This Project
    ... RegLoginServlet.java - Java source code for your registration / login ... CatServlet.java - Java source code for your catalog index servlet. ... ShopCartServlet.java - Java source code for the shopping cart servlet. ... If there is, that session should be invalidated, ...
    (comp.lang.java.help)

Quantcast