Delphi For PHP Forums       


Go Back   Delphi-PHP Forums > Delphi For PHP > VCL4PHP
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

VCL4PHP VCL for PHP. Questions or comments about the Visual Component Library for PHP, post them here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 27th June 2009, 16:20
D4PHP User
 
Join Date: Dec 2008
Posts: 46
Holgerwa is on a distinguished road
Default VCL corrupts session?

I do something like this directly at the top of a page that requires to be logged in:
PHP Code:
<?php
  session_start
();
  if (
$_SESSION ['LOGGEDIN'] != true)
  {
    
header ("Location: login.php");
    exit;
  }
This happens before all the VCL-includes. There are also other $_SESSION variables I set when the user logs in.
When this page is loaded, the VCL adds a whole bunch of additional values to the $_SESSION array.

Now I am logged in and the page is shown as should be.
If I load the page again in another browser tab, the above code still "sees" LOGGEDIN as true and doesn't redirect to login.php.
But when the VCL include:
PHP Code:
use_unit("forms.inc.php"); 
happens, the contents of all my $_SESSION variables is deleted. They are still "isset" but have no contents anymore.

That results in the page being shown but with no meaningful contents because the $_SESSION values are not there anymore.

Now I am not sure if opening the logged in page again in another browser tab is considered to be a new session or not.

But if it should be a new session, why are the $_SESSION variables still valid at the beginning of the php script?

If it should not be a new session and the user should be logged in at the new tab, too, why does the VCL delete my $_SESSION variables?

Thanks for any insight!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28th June 2009, 03:58
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,216
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

It may be:
if you are running it out of the IDE it auto appends restore_session=1 to it and that clears session.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 28th June 2009, 17:12
D4PHP User
 
Join Date: Dec 2008
Posts: 46
Holgerwa is on a distinguished road
Default

Yes, I am running it out of the IDE, so that might cause the problem.

How would I run it without the IDE, but locally on my machine (Windows XP PC)?
The IDE creates some URLs that seem to call PHP to run the scripts. Is there an easy way to do this manually?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 29th June 2009, 04:25
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,216
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

apache friends - very easy apache, mysql, php and perl installation without hassles

But you can also run them after deleting the restore_session from the url.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 29th June 2009, 09:39
D4PHP User
 
Join Date: Dec 2008
Posts: 46
Holgerwa is on a distinguished road
Default

Great, thanks, I'll try this.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 30th June 2009, 10:07
D4PHP User
 
Join Date: Dec 2008
Posts: 46
Holgerwa is on a distinguished road
Default

Yes, that was the problem, it all works without restore_session from the IDE :-)
Thanks a lot!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 30th June 2009, 15:05
D4PHP User
 
Join Date: Dec 2008
Posts: 46
Holgerwa is on a distinguished road
Default

I found this post about restore_session, which seems to solve the problem:
VCL for PHP :: View topic - Avoid "?restore_session=1" and keep session data

Question: Wouldn't it be easier to just get rid of the GET-variable "restore_session" if it exists?
Something like
PHP Code:
if (isset($_GET['restore_session']))
  unset(
$_GET['restore_session']) 
If this is done right at the top of the PHP file, it cannot do any harm and it's only one line to add instead of the solution in that post.

It seems to work fine, or do I miss anything?

Last edited by Holgerwa; 30th June 2009 at 15:13.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 30th June 2009, 17:52
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,216
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

The ide is the only thing that automatic appends restore_session so normally it isn't a problem.

The reason you must be able to use it is when you make program changes things just don't change because of persistence. If you always wipe it out then you will have to close and reopen all instances of your browser to reset the cookie.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 4th July 2009, 16:12
D4PHP User
 
Join Date: Dec 2008
Posts: 46
Holgerwa is on a distinguished road
Default

Thanks for the explanation, that makes sense :-)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 12:08.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use