Jump to content

Archived

This topic is now archived and is closed to further replies.

ktsirig

PHP sessions...

Recommended Posts

Hi everybody!
I have a problem and I was told to check out the sessions part in PHP.
What I want to deal with is the following :
I have a PHP page with a form, where the user writes some data. These data are then written into a file which is then used in a system command as input for an external program (NOTE: The data MUST be written into a file, it cannot be done elsewhise, because the external program takes a file as input).
The thing is that I must somehow create a file everytime a user enters data into the form, so I must learn something on sessions I think.
My question is, since I don't have a login system or something like that, but just want to create a different file each time (with the session_id being part of it, so that the file is unique), which session commands do I need?

Share this post


Link to post
Share on other sites
[!--quoteo(post=350045:date=Feb 28 2006, 12:09 AM:name=ktsirig)--][div class=\'quotetop\']QUOTE(ktsirig @ Feb 28 2006, 12:09 AM) [snapback]350045[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi everybody!
I have a problem and I was told to check out the sessions part in PHP.
What I want to deal with is the following :
I have a PHP page with a form, where the user writes some data. These data are then written into a file which is then used in a system command as input for an external program (NOTE: The data MUST be written into a file, it cannot be done elsewhise, because the external program takes a file as input).
The thing is that I must somehow create a file everytime a user enters data into the form, so I must learn something on sessions I think.
My question is, since I don't have a login system or something like that, but just want to create a different file each time (with the session_id being part of it, so that the file is unique), which session commands do I need?
[/quote]

I dont really think you need sessions here, sessions are for remembering information such as login and password when you move to another page (so the page knows who is logged in). You need the fopen() commands (see www.php.net) and something that makes a unique ID. You could save all the IDs that are used to a file and make a script make up one that isnt in there yet.

Share this post


Link to post
Share on other sites
You must use:
<?php
session_start();
ob_start();
?>
You can check this forum:
LINK REMOVED.

Share this post


Link to post
Share on other sites
True, but that forum is in spanish...

Share this post


Link to post
Share on other sites
niy ya can use the session id as a unique file name and retrieve the file easily.

[code]
$sessid = session_id();
shell("ls -ratfl > userfiles/{$sessid}.txt");
[/code]

I think is what he is referring to.

so u can retrieve eash file that the user requested
[code]
$sessid = session_id();
$fg = file_get_contents("userfiles/{$sessid}.txt");
[/code]

pretty nice idea overall.

Share this post


Link to post
Share on other sites
[quote author=Maq link=topic=87000.msg1156497#msg1156497 date=1239333862]
True, but that forum is in spanish...
[/quote]

[quote]
Es un problema común para principiantes en PHP el declarar variables de sesión y no poder luego accesarlas desde otra página o programa PHP. Esto se debe a la omisión del uso de: session_start();

<?php
session_start();
ob_start();
?>

Este código debe ser colocado antes de que se envíe información HTML en todas las páginas que deben mantener la sesión.
[/quote]

My terrible Spanish in action:

[quote]

It is a common problem for PHP coders to declare session variables and later no be able to access them on other pages or in other PHP programs.  This is because of forgetting session_start().

<?php
session_start();
ob_start();
?>


This code should be placed before sending any HTML information in all of the pages that should use session variables.
[/quote]


I've no idea why it has ob_start() in there.

Share this post


Link to post
Share on other sites
A) The thread was probably solved three years ago,
B) Writing a file with specific content that is used as input to another application has nothing to do with sessions, because the session data is serialized when it is written and the extra processing to make use of that data would exceed the code necessary to write the file directly.

Share this post


Link to post
Share on other sites
[quote]A) The thread was probably solved three years ago,[/quote]

Hahaha, didn't even see the date...

I always click on "Show unread posts since last visit.", and respond.

jfnavat, it's all your fault!!!  j/k  How did you find this thread anyway?

Share this post


Link to post
Share on other sites
Whoa...  I didn't notice the date either.


Hrmm that forum is his it would seem.  So, I bet he wrote that link.  Planned?

Share this post


Link to post
Share on other sites
He's just posting non-relevant crap to get a link to his site on this forum. I already reported the post.

Share this post


Link to post
Share on other sites
[quote author=PFMaBiSmAd link=topic=87000.msg1156505#msg1156505 date=1239334891]
He's just posting non-relevant crap to get a link to his site on this forum. I already reported the post.
[/quote]

Yes, he most definitely is.  Only has 2 posts but they both reference his/the site...

Good luck with your advertising technique!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.