Jump to content


data from session


6 replies to this topic

#1 curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 21 May 2007 - 11:26 AM

ok, i can write read to session fine, thats not the problem,

my problem is, my online tutorial editor for my cms uses sessions to store virtual files so there is no files on the server for content :P

problem

each file tht is opened and $_SESSION[$file] = $text where $file is the file name and $text being the content of the file.

thats all good, i can open loads up, type in the url what file and wala, start editing from the session again..

but...

how do i like, print a list of whats in the session,

as if i have like 5 virtual files in the session, how can i generate a select box or sumthing with those 5 file names in so u can select and go back to editing them again? as the files r all the files names, u can predo the select box....understand? lol

any help would be appreciated,

#2 Case

    Young Padawan

  • Members
  • Pip
  • 207 posts
  • Gender:Male
  • Location:Birmingham, UK

Posted 21 May 2007 - 11:39 AM

If what you're trying to say is "how can I get back the session variables after I've left the site for a bit", the answer is you cant. When you leave the session ends and the data is lost. The best way to go about storing data is a MYSQL database.

If you are asking "how to I detect what session variables are active": $_SESSION is an array and so your $file and $text are actually segments of a two dimentional array and this functions just like a normal variable array.

For example:

<?PHP
Print_r ($_SESSION)
?>

This will print the contents of all the array variables contained within $_SESSION to the screen.

I'm sure you can find your way from here, just treat it as a normal array and loop through using a foreach statement. :P

#3 curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 21 May 2007 - 11:59 AM

				<?php
					$session = $_SESSION;
					foreach($session as $key => $value){
						if(!eregi('temp/',$key)){
							continue;
						}
						$getfile = explode('temp/', $key);
					}
				?>

cheers man, just started to ream tht crap out of my head lol, kinda scary, and it works....but ths not all of it lol, only sumthing im editing now.


full thing looks like

<select name="file">
				<?php
					$session = $_SESSION;
					foreach($session as $key => $value){
						if(!eregi('temp/',$key)){
							continue;
						}
						$getfile = explode('temp/', $key);
						$file = $getfile[1];
						$list .= '<option value="'.$file.'>'.$file.'</option>';
					}
				?>
					<option>-- Previously Edited File --</option>
						<?=$list?>
				</select>

:D

Edited by curthard89, 21 May 2007 - 12:04 PM.


#4 Case

    Young Padawan

  • Members
  • Pip
  • 207 posts
  • Gender:Male
  • Location:Birmingham, UK

Posted 21 May 2007 - 12:16 PM

May I ask why you are using $_SESSION and not MYSQL? :D

#5 curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 21 May 2007 - 01:06 PM

take alook urself :D its up and running, go to my cms and click editor..

www.ultimate-tutorials.co.uk

login with

demo and demo

basically, it uploads a file to edit, gets content, stores it in a session

then deletes the file,

so ur working with sessions when u edit.

that what i just coded allows u to change through the files that are in the session....

capiche?

so no files r involved apart from the 1st bit

#6 Case

    Young Padawan

  • Members
  • Pip
  • 207 posts
  • Gender:Male
  • Location:Birmingham, UK

Posted 21 May 2007 - 02:03 PM

I remember seeing this when you posted it a while back, lovely GUI :D

So you're using MYSQL and then SESSION for the editing?

#7 curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 21 May 2007 - 02:10 PM

for editing files im using session :)

everything else is mysql





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users