Hello,
How can I use the php session functions.
My module dont restore variables stocked via $_SESSION['myVar'] = "value" ;
Cedric
PHP session
- pelloq1
- Joomla! Enthusiast
- Posts: 145
- Joined: Sat Dec 16, 2006 7:42 am
- Location: Switzerland
PHP session
Z. Rick
http://www.myjoom.com quality joomla extensions
http://extensions.joomla.org/extensions/owner/pelloq1
http://www.myjoom.com quality joomla extensions
http://extensions.joomla.org/extensions/owner/pelloq1
- dam-man
- Joomla! Exemplar
- Posts: 7961
- Joined: Fri Sep 09, 2005 2:13 pm
- Location: The Netherlands
- Contact:
Re: PHP session
Hi
Joomla! 1.0 is not starting a session like you want. So what you want is not working.
Take a look at virtuemart, they're starting a session right there
And a small example that is wrking on my localhost:
Joomla! 1.0 is not starting a session like you want. So what you want is not working.
Take a look at virtuemart, they're starting a session right there
And a small example that is wrking on my localhost:
Code: Select all
<?php
## Check if Joomla enters this page, if not? Die this script immediatly.
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
## Starting a session
session_start();
global $database;
## Get the function from the URL.
$func = mosGetParam( $_GET, 'func' );
## If the session didn't started, stop the script.
if( empty( $_SESSION ) || session_id() == '') {
echo "Something went wrong..";
}
## Switch Functions here.
switch ($func) {
case "check":
check();
break;
case "formsucces":
formsucces();
break;
default:
form();
}
function check(){
echo "Your Name: ".$_SESSION['name']."<br>";
echo "Your Email: ".$_SESSION['email']."<br>";
}
function formsucces(){
$_SESSION['name'] = mosGetParam( $_REQUEST, 'name') ;
$_SESSION['email'] = mosGetParam( $_REQUEST, 'email') ;
echo "Your Form is submitted Succesfull!";
?>
<a href="index.php?option=com_dailymessage&Itemid=26&func=check" target="_self">Ga verder met testen!</a>
<?php
}
function form() { ?>
<h1 class=contentheading>Test Het Script
</h1>
<form action="<?php echo sefRelToAbs( 'index.php?option=com_dailymessage&func=formsucces'); ?>" method="post" name="S2Form">
<table width=100% border=0 cellspacing=1 cellpadding=0>
<tr>
<td width=25%>Naam</td>
<td width=22%><input type="text" size="30" class="inputbox" name="name" value="<?php echo mosGetParam( $_POST, 'name'); ?>" /></td>
<td width=53% rowspan="5" align="left" valign="top"> </td>
</tr>
<tr>
<td>E-mail Adres</td>
<td><input type="text" class="inputbox" size="30" name="email" value="<?php echo mosGetParam( $_POST, 'email'); ?>" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" class="button" name="Submit" value="Test Snel" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<?php }
?>
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards
Dutch Boards | Joomla Coding Boards | English Support Boards
- pelloq1
- Joomla! Enthusiast
- Posts: 145
- Joined: Sat Dec 16, 2006 7:42 am
- Location: Switzerland
Re: PHP session
Hello,
I have learn the the
## Starting a session
session_start();
function must allway placed at the start (before php write anything in the browser) of the file ... Can I set the session_start in a module ??
Cédric
I have learn the the
## Starting a session
session_start();
function must allway placed at the start (before php write anything in the browser) of the file ... Can I set the session_start in a module ??
Cédric
Z. Rick
http://www.myjoom.com quality joomla extensions
http://extensions.joomla.org/extensions/owner/pelloq1
http://www.myjoom.com quality joomla extensions
http://extensions.joomla.org/extensions/owner/pelloq1
- dam-man
- Joomla! Exemplar
- Posts: 7961
- Joined: Fri Sep 09, 2005 2:13 pm
- Location: The Netherlands
- Contact:
Re: PHP session
Session must be started before output, that's correct.
Below is no output, but PHP:
Just give it a try in your module
Below is no output, but PHP:
OUtput is when you write something to screens like HTMLdefined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
Just give it a try in your module
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards
Dutch Boards | Joomla Coding Boards | English Support Boards
- pelloq1
- Joomla! Enthusiast
- Posts: 145
- Joined: Sat Dec 16, 2006 7:42 am
- Location: Switzerland
Re: PHP session
Ok I go to test it, but I dont understand that we send the session_start because before the draw of my module, it's many ouput in html (other modules, template ...)
Ced
Ced
Z. Rick
http://www.myjoom.com quality joomla extensions
http://extensions.joomla.org/extensions/owner/pelloq1
http://www.myjoom.com quality joomla extensions
http://extensions.joomla.org/extensions/owner/pelloq1
- dam-man
- Joomla! Exemplar
- Posts: 7961
- Joined: Fri Sep 09, 2005 2:13 pm
- Location: The Netherlands
- Contact:
Re: PHP session
Try it, in my component it works great.
I can make a webshop for a specific client now
I can make a webshop for a specific client now
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards
Dutch Boards | Joomla Coding Boards | English Support Boards
- pelloq1
- Joomla! Enthusiast
- Posts: 145
- Joined: Sat Dec 16, 2006 7:42 am
- Location: Switzerland
Re: PHP session
Hello,
YES ! It's work.
Thank you
YES ! It's work.
Thank you
Z. Rick
http://www.myjoom.com quality joomla extensions
http://extensions.joomla.org/extensions/owner/pelloq1
http://www.myjoom.com quality joomla extensions
http://extensions.joomla.org/extensions/owner/pelloq1
- dam-man
- Joomla! Exemplar
- Posts: 7961
- Joined: Fri Sep 09, 2005 2:13 pm
- Location: The Netherlands
- Contact:
Re: PHP session
Great!
Good luck with your site and module!
Good luck with your site and module!
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards
Dutch Boards | Joomla Coding Boards | English Support Boards