<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mukesh Chapagain&#039;s Blog &#187; session</title>
	<atom:link href="http://blog.chapagain.com.np/tag/session/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chapagain.com.np</link>
	<description>PHP Magento jQuery SQL Wordpress Joomla Programming &#38; Tutorial</description>
	<lastBuildDate>Tue, 31 Jan 2012 20:16:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Magento: Get Set Unset Session</title>
		<link>http://blog.chapagain.com.np/magento-set-unset-session/</link>
		<comments>http://blog.chapagain.com.np/magento-set-unset-session/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 19:21:09 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=250</guid>
		<description><![CDATA[Set a custom session with Variable Name &#8216;testing_magento&#8217;. The session value here is &#8216;hello&#8217;. Mage::getSingleton('core/session')->setTestingMagento('hello'); Get session testing_magento $test = Mage::getSingleton('core/session')->getTestingMagento(); Unset session Mage::getSingleton('core/session')->setTestingMagento(); (Use customer or core session in frontend. Use adminhtml session in the backend.) Core Session:- Mage::getSingleton(&#8216;core/session&#8217;) Customer Session:- Mage::getSingleton(&#8216;customer/session&#8217;) Admin Session:- Mage::getSingleton(&#8216;adminhtml/session&#8217;) Copyright &#169; 2011 This feed is for personal, non-commercial [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-send-email-easily-using-zend_mail/' rel='bookmark' title='Permanent Link: Magento: Send email easily using Zend_Mail'>Magento: Send email easily using Zend_Mail</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-get-admin-user-id-name-username-email-etc/' rel='bookmark' title='Permanent Link: Magento: How to get admin user id, name, username, email, etc?'>Magento: How to get admin user id, name, username, email, etc?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-block-controller-model-helper-override/' rel='bookmark' title='Permanent Link: Magento: Block Controller Model Helper Override'>Magento: Block Controller Model Helper Override</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-run-magento-code-in-an-external-website/' rel='bookmark' title='Permanent Link: Magento: How to run Magento code in an external website?'>Magento: How to run Magento code in an external website?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Set a custom session with Variable Name &#8216;testing_magento&#8217;. The session value here is &#8216;hello&#8217;.<br />
<code>Mage::getSingleton('core/session')->setTestingMagento('hello');</code></p>
<p>Get session testing_magento<br />
<code>$test = Mage::getSingleton('core/session')->getTestingMagento();</code></p>
<p><span id="more-250"></span></p>
<p>Unset session<br />
<code>Mage::getSingleton('core/session')->setTestingMagento();</code></p>
<p>(Use customer or core session in frontend. Use adminhtml session in the backend.)<br />
Core Session:- Mage::getSingleton(&#8216;core/session&#8217;)<br />
Customer Session:- Mage::getSingleton(&#8216;customer/session&#8217;)<br />
Admin Session:- Mage::getSingleton(&#8216;adminhtml/session&#8217;)</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=250&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-send-email-easily-using-zend_mail/' rel='bookmark' title='Permanent Link: Magento: Send email easily using Zend_Mail'>Magento: Send email easily using Zend_Mail</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-get-admin-user-id-name-username-email-etc/' rel='bookmark' title='Permanent Link: Magento: How to get admin user id, name, username, email, etc?'>Magento: How to get admin user id, name, username, email, etc?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-block-controller-model-helper-override/' rel='bookmark' title='Permanent Link: Magento: Block Controller Model Helper Override'>Magento: Block Controller Model Helper Override</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-run-magento-code-in-an-external-website/' rel='bookmark' title='Permanent Link: Magento: How to run Magento code in an external website?'>Magento: How to run Magento code in an external website?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-set-unset-session/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Very simple add, edit, delete, display in PHP</title>
		<link>http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/</link>
		<comments>http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 08:03:11 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[edit]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[register]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2008/03/05/very-simple-add-edit-delete-display-in-php/</guid>
		<description><![CDATA[Before I had posted an article to add, edit, delete, and display contents. I had also included sessions there. There was the facility to login and register users too. But i got feedback that it was a bit complex for novice users of PHP (users who have just started PHPing). It was a kind of [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/' rel='bookmark' title='Permanent Link: Add, edit, delete, login, register in PHP :: A simple and complete tutorial'>Add, edit, delete, login, register in PHP :: A simple and complete tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
<li><a href='http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/' rel='bookmark' title='Permanent Link: Fun with strings in PHP (Part 1)'>Fun with strings in PHP (Part 1)</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-select-insert-update-and-delete-data/' rel='bookmark' title='Permanent Link: Magento: How to select, insert, update, and delete data?'>Magento: How to select, insert, update, and delete data?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Before I had posted an article to <a href="http://blog.chapagain.com.np/2007/12/08/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/">add, edit, delete, and display contents</a>. I had also included sessions there. There was the facility to login and register users too.</p>
<p>But i got feedback that it was a bit complex for novice users of PHP (users who have just started PHPing). It was a kind of full-fledge system with PHP, MySQL and session.</p>
<p><span id="more-44"></span></p>
<p>So in this article, I have simplified the same functionality of the above tutorial. I have not used session in this case. If you want tutorial about session, login, and register then you can refer to my previous article (the link which is provided above).</p>
<p><strong>Files included in this tutorial/code:</strong></p>
<p>users.sql = This contains sql queries to make MySQL database and table</p>
<p>config.php = contains the database connection code (this file is included in all the php pages with the include() function)</p>
<p>index.php = contains the display part (displaying data from database)</p>
<p>add.html = contains form to add data</p>
<p>add.php = contains php code to add data</p>
<p>edit.php = contains php code to edit data</p>
<p>delete.php = contains php code to delete data</p>
<p><strong>Download full source code: <a href="http://chapagain.googlecode.com/files/crud-simple.zip" title="Create, read, update, delete in php and mysql">Create, read, update, delete in php and mysql</a></strong></p>
<p>Cheers,</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=44&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/' rel='bookmark' title='Permanent Link: Add, edit, delete, login, register in PHP :: A simple and complete tutorial'>Add, edit, delete, login, register in PHP :: A simple and complete tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
<li><a href='http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/' rel='bookmark' title='Permanent Link: Fun with strings in PHP (Part 1)'>Fun with strings in PHP (Part 1)</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-select-insert-update-and-delete-data/' rel='bookmark' title='Permanent Link: Magento: How to select, insert, update, and delete data?'>Magento: How to select, insert, update, and delete data?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Session Handling in PHP</title>
		<link>http://blog.chapagain.com.np/session-handling-in-php/</link>
		<comments>http://blog.chapagain.com.np/session-handling-in-php/#comments</comments>
		<pubDate>Mon, 14 May 2007 23:54:42 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=10</guid>
		<description><![CDATA[At first create database named &#8216;test&#8217; in mysql. Use &#8216;test&#8217;. Then create table &#8216;project&#8217;. MySQL queries for the above tasks :: Now the php code:: config.php register.php login.php logout.php secret.php Download full source code: Session Handling in PHP Cheers, Copyright &#169; 2011 This feed is for personal, non-commercial use only. The use of this feed [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/' rel='bookmark' title='Permanent Link: Fun with strings in PHP (Part 1)'>Fun with strings in PHP (Part 1)</a></li>
<li><a href='http://blog.chapagain.com.np/regular-expression-check-validation-in-php/' rel='bookmark' title='Permanent Link: Regular Expression check, Validation in PHP'>Regular Expression check, Validation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/' rel='bookmark' title='Permanent Link: Very simple add, edit, delete, display in PHP'>Very simple add, edit, delete, display in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/magento-set-unset-session/' rel='bookmark' title='Permanent Link: Magento: Get Set Unset Session'>Magento: Get Set Unset Session</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>At first create database named &#8216;test&#8217; in mysql. Use &#8216;test&#8217;. Then create table &#8216;project&#8217;.</p>
<p>MySQL queries for the above tasks ::</p>
<pre class="brush: sql; title: ; notranslate">
create database test;
use test;
create table project (id int(9) not null auto_increment, username varchar(50), password varchar(50), time datetime, primary key(id));
</pre>
<p>Now the php code::</p>
<p><span id="more-10"></span></p>
<p>config.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

// $dbhost is a variable and holds the localhost or server name
$dbhost = &quot;localhost&quot;; 

// $dbusername is a variable and holds the database username
// i.e. the username of your database server (mine is set to null)
$dbusername = &quot;root&quot;; 

// $dbpassword holds username password
// i.e. the password of your database server (there is no password in my case)
$dbpassword = &quot;&quot;; 

// $dbname holds the database name
$dbname = &quot;test&quot;; 

// $connect is a variable and stores the connection for future use
// in this case &quot;die&quot; is used to display error message in case the connection with the database fails
$connect = mysql_connect($dbhost,$dbusername,$dbpassword)
	or die (&quot;Could not connect to database&quot;); 

// in this case &quot;or die()&quot; - statement is used to display error message
// incase there is no database with the database name provided
mysql_select_db($dbname,$connect)
	or die (&quot;Could not select database&quot;); 

?&gt;
</pre>
<p>register.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Register&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;br/&gt;&lt;h2&gt;User Registration ::&lt;/h2&gt;
&lt;form action=&quot;&lt;?php $_SERVER['PHP_SELF']; ?&gt;&quot; method=&quot;post&quot;&gt;
	&lt;table&gt;
		&lt;tr&gt;&lt;td&gt;Username&lt;/td&gt;&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;user&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
		&lt;tr&gt;&lt;td&gt;Password&lt;/td&gt;&lt;td&gt;&lt;input type=&quot;password&quot; name=&quot;pass&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
		&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
	&lt;/table&gt;
&lt;/form&gt;

&lt;?php
include(&quot;config.php&quot;);
$user = $_POST['user'];
$pass = $_POST['pass']; 

// checking whether the username or password field is empty or not
if($user == &quot;&quot; || $pass == &quot;&quot;)
{
	echo &quot;&lt;font color='red'&gt;Please fill in all the fields.&lt;/font&gt;&quot;;
}
else
{
	// inserting the form values to the database
	$result = mysql_query(&quot;insert into project(username,password,dtime) values ('$user','$pass',now())&quot;,$connect)
	or die (mysql_error()); // or displaying the error
	echo &quot;&lt;font color='green'&gt;Data entered successfully. To login &lt;a href='login.php'&gt;click here&lt;/a&gt;&lt;/font&gt;&quot;;
}
?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>login.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php session_start(); // session started at the top ?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Login&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php
include(&quot;config.php&quot;);
$user = $_POST['user'];
$pass = $_POST['pass']; 

$result = mysql_query(&quot;select * from project where password='$pass' and username='$user'&quot;,$connect)
or die(mysql_error());

while($username = mysql_fetch_assoc($result)) // fetching the associative array
{
	$_SESSION['valid'] = $user; // giving a name username to the session variable
}

if(isset($_SESSION['valid'])) // checking if the session variable is set or not
{
	echo &quot;&lt;font color='#0099cc'&gt;&lt;h2&gt;Welcome! &quot;.$_SESSION['valid'].&quot; &lt;/h2&gt;&lt;/font&gt;&quot;;
	echo &quot;&lt;br/&gt;&quot;;
	echo &quot;&lt;a href='secret.php'&gt;Secret Page&lt;/a&gt; || &lt;a href='logout.php'&gt;Logout&lt;/a&gt;&quot;;
}
else
{
	if(isset($user))
	{
		echo &quot;&lt;font color='red'&gt;Invalid username or password.&lt;/font&gt;&quot;; // if invalid attempt is made to login
	}
	else
	{
		echo &quot;&lt;font color='green'&gt;You are not logged in.&lt;/font&gt;&quot;; // message to be displayed when the login page is loaded at first
	}
	// below the message, the login form is displayed
	?&gt;
&lt;br/&gt;&lt;h2&gt;Login ::&lt;/h2&gt;
	&lt;form action=&quot;&lt;?php $_SERVER['PHP_SELF']; ?&gt;&quot; method=&quot;post&quot;&gt;
		&lt;table&gt;
			&lt;tr&gt;&lt;td&gt;Username&lt;/td&gt;&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;user&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
			&lt;tr&gt;&lt;td&gt;Password&lt;/td&gt;&lt;td&gt;&lt;input type=&quot;password&quot; name=&quot;pass&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
			&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
			&lt;td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/td&gt;
			&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Not registered yet? &lt;a href=&quot;register.php&quot;&gt;Register&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
		&lt;/table&gt;
	&lt;/form&gt;
&lt;?
}
?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>logout.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php session_start(); // session is started at the begining of the page ?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Logout&lt;/title&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;?php
session_destroy(); // destroying the session variable
echo &quot;You have been successfully logged out.&quot;; // displaying the message
echo &quot;&lt;br/&gt;&lt;br/&gt;&lt;a href='login.php'&gt;Login&lt;/a&gt; || &lt;a href='register.php'&gt;Register&lt;/a&gt;&quot;;
?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>secret.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php session_start(); ?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Secret Page&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php
include(&quot;config.php&quot;);

if(isset($_SESSION['valid'])) // checking if the session variable is set or not
{
	// if the user is authorized then displaying the message in green color
	echo &quot;&lt;font color='green'&gt;You are authorized to view this page &quot;.$_SESSION['valid'].&quot;!&lt;/font&gt;&quot;;
	echo &quot;&lt;br/&gt;&lt;br/&gt;&lt;a href='logout.php'&gt;Logout&lt;/a&gt;&quot;;
}
else
{
	// if the user is not authorized then displaying the message in red color
	echo &quot;&lt;font color='red'&gt;You are not authorized to view this page.&lt;/font&gt;&quot;;
	echo &quot;&lt;br/&gt;&lt;br/&gt;&lt;a href='login.php'&gt;Login&lt;/a&gt; || &lt;a href='register.php'&gt;Register&lt;/a&gt;&quot;;
}
?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><strong>Download full source code: <a href="http://chapagain.googlecode.com/files/session-handling.zip" title="Session Handling in PHP">Session Handling in PHP</a></strong></p>
<p>Cheers,</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=10&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/' rel='bookmark' title='Permanent Link: Fun with strings in PHP (Part 1)'>Fun with strings in PHP (Part 1)</a></li>
<li><a href='http://blog.chapagain.com.np/regular-expression-check-validation-in-php/' rel='bookmark' title='Permanent Link: Regular Expression check, Validation in PHP'>Regular Expression check, Validation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/' rel='bookmark' title='Permanent Link: Very simple add, edit, delete, display in PHP'>Very simple add, edit, delete, display in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/magento-set-unset-session/' rel='bookmark' title='Permanent Link: Magento: Get Set Unset Session'>Magento: Get Set Unset Session</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/session-handling-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
