Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Keeping Users Logged in Outside Catalog


sebconn

Recommended Posts

Is there an easy way I can keep users logged when they venture outside the catalog directory?

 

I've got the form on the main page working to log them in , but I want them to stay logged in when they go to other sections in the site.

Link to comment
Share on other sites

Is there an easy way I can keep users logged when they venture outside the catalog directory?

 

I've got the form on the main page working to log them in , but I want them to stay logged in when they go to other sections in the site.

 

integrate the other pages of your site into osC and use tep_href_link to switch between pages, just like you do it for the pages in teh information box right now.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

integrate the other pages of your site into osC and use tep_href_link to switch between pages, just like you do it for the pages in teh information box right now.

 

not too sure of the correct syntax for that, In a link in the catalog directory that leads outside the directory I tried using

 

 <a href="' . tep_href_link('http://www.domain.com.au/index.php') . '">Home</a><br>

 

but that returned the link http://www.domain.com.au/catalog/http://www.domain.com.au/index.php

Link to comment
Share on other sites

I'd prefer not to do that if possible.

I had the same issue recently and whyt I did I created a new function, as the current one always adds the full domain path as you have noticed. Of course you need to keep the old one, the new one is just an add on!!!

 

Plase the following into the

includes\functions\html_output.php file and let me know if it does for you what it should, when using it for the links that are to go one level up:

 

////
// The *********NEW******* HTML href link wrapper function, takes you one level up!
 function tep_href_link_top($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
global $request_type, $session_started, $SID;

if (!tep_not_null($page)) {
  die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');
}

if ($connection == 'NONSSL') {
  $link = HTTP_SERVER . '/';
} elseif ($connection == 'SSL') {
  if (ENABLE_SSL == true) {
	$link = HTTPS_SERVER . '/';
  } else {
	$link = HTTP_SERVER . '/';
  }
} else {
  die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>');
}

if (tep_not_null($parameters)) {
  $link .= $page . '?' . tep_output_string($parameters);
  $separator = '&';
} else {
  $link .= $page;
  $separator = '?';
}

while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
  if (tep_not_null($SID)) {
	$_sid = $SID;
  } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
	if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
	  $_sid = tep_session_name() . '=' . tep_session_id();
	}
  }
}

if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
  while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);

  $link = str_replace('?', '/', $link);
  $link = str_replace('&', '/', $link);
  $link = str_replace('=', '/', $link);

  $separator = '?';


}

if (isset($_sid)) {
  $link .= $separator . $_sid;
}

return $link;
 }

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

I had the same issue recently and whyt I did I created a new function, as the current one always adds the full domain path as you have noticed. Of course you need to keep the old one, the new one is just an add on!!!

 

Plase the following into the

includes\functions\html_output.php file and let me know if it does for you what it should, when using it for the links that are to go one level up:...

 

Your function worked great but I still get logged out as soon as I leave the catalog directory, I'll keep working on it, might be a slight prob with something else I've done

Link to comment
Share on other sites

 

that solution is does the same thing as Monika's function, keeps the session ID in the URL, but it's still not working for me.

 

the navigation links I am using are in a very basic info box I have sitting in the store, nothing special, just a page with the nav links that I can easily move around using STS. Here's the code:

 

				<ul class="sidebar">
	<li><?php echo '<a href=' . tep_href_link_top('index.php') . '>Home</a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('index.php','loc=about') . '">About</a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('shop/index.php') . '><strong>Online Store</strong></a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('index.php','loc=specialist') . '>Specialist</a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('index.php','loc=bussol') . '>Business Solutions</a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('index.php','loc=edu') . '>Focus on Education</a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('index.php','loc=gaming') . '>Extreme Gaming</a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('index.php','loc=student') . '>Student Packages</a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('index.php','loc=power') . '>Power (Expert) Users</a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('index.php','loc=repairs') . '>Rapid Repairs</a>'; ?></li>
	<li><?php echo '<a href=' . tep_href_link_top('index.php','loc=contact') . '>Contact Us</a>'; ?></li>
	</ul>

 

I include the exact same code in the pages outside of my shop, but the links inside the catalog directory don't seem to put the OSCID variable into the links, yet the outside ones do. And, as expected, if I go into the catalog dir and then back out, the OSCID has changed when I look at the links. I'm slightly weirded out now.

Link to comment
Share on other sites

does the link that brings you back to the shop have the osCsid in it

 

yes, but that changes each time you go in and out of the shop.

 

I should mention that I have included in the pages outside the shop dir I have a modified version of application_top (application_top_2.php, in the same location as application top) which the include locations in that are modified (and nothing else) so I can use the infobox anywhere contribution. I might remove this for a moment just to see if that's causing the issue. but if the links in the shop dir are not passing on the session variable to the outside pages then it's less than likely to be the issue.

 

then again it could be starting a new session somewhere int he application_top_2 file. but if it's a pretty much direct copy of application_top it shouldn't be the case.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...