Vremensko i cookie ograničenje

Ja lično razumijem jS i druhe jezike ali ja :neznam: njihove naredbe i iz tog razloga bih zamolio one koji znaju i koji mi mogu da pomognu neka pomognu

treba mi sljedeće:
javaskript koja provjerava vrijeme (znači vremensko ograničenje od nekoliko sati zavisno od otga koliko je namješteno ) znači trebam negdje u kodu da stavim od toiko do toliko i onda će se izvršavati dalje
provjera cookieja da li je ta osoba već gledala stranicu ako je redirektuje je negdje , a ako nije nastavi učitanje sajta i zakači joj isti cookie
znači da svaka osoba može samo jednom da pročita stranicu i naravno da mogu promjeniti vrijednost cookie (naziv ili neš slično tako da nebude uvjek isti ali ništa automatski znači ja ručno)

Pozovi prikačene js-ove u dokumentu sa

Cookie valja do sljedećeg punog sata.

Neznam zašto ih nije prikačilo. Evo ih u kodu:<span class="syntaxdefault"></span><span class="syntaxkeyword"><!--<br /><br /></span><span class="syntaxcomment">/*<br />&nbsp;&nbsp;&nbsp;name&nbsp;-&nbsp;name&nbsp;of&nbsp;the&nbsp;cookie<br />&nbsp;&nbsp;&nbsp;value&nbsp;-&nbsp;value&nbsp;of&nbsp;the&nbsp;cookie<br />&nbsp;&nbsp;&nbsp;[expires]&nbsp;-&nbsp;expiration&nbsp;date&nbsp;of&nbsp;the&nbsp;cookie<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(defaults&nbsp;to&nbsp;end&nbsp;of&nbsp;current&nbsp;session)<br />&nbsp;&nbsp;&nbsp;[path]&nbsp;-&nbsp;path&nbsp;for&nbsp;which&nbsp;the&nbsp;cookie&nbsp;is&nbsp;valid<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(defaults&nbsp;to&nbsp;path&nbsp;of&nbsp;calling&nbsp;document)<br />&nbsp;&nbsp;&nbsp;[domain]&nbsp;-&nbsp;domain&nbsp;for&nbsp;which&nbsp;the&nbsp;cookie&nbsp;is&nbsp;valid<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(defaults&nbsp;to&nbsp;domain&nbsp;of&nbsp;calling&nbsp;document)<br />&nbsp;&nbsp;&nbsp;[secure]&nbsp;-&nbsp;Boolean&nbsp;value&nbsp;indicating&nbsp;if&nbsp;the&nbsp;cookie&nbsp;transmission&nbsp;requires<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;secure&nbsp;transmission<br />&nbsp;&nbsp;&nbsp;*&nbsp;an&nbsp;argument&nbsp;defaults&nbsp;when&nbsp;it&nbsp;is&nbsp;assigned&nbsp;null&nbsp;as&nbsp;a&nbsp;placeholder<br />&nbsp;&nbsp;&nbsp;*&nbsp;a&nbsp;null&nbsp;placeholder&nbsp;is&nbsp;not&nbsp;required&nbsp;for&nbsp;trailing&nbsp;omitted&nbsp;arguments<br />*/<br /><br /></span><span class="syntaxkeyword">function&nbsp;</span><span class="syntaxdefault">setCookie</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">name</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">value</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">expires</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">domain</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">secure</span><span class="syntaxkeyword">)&nbsp;{<br />&nbsp;&nbsp;var&nbsp;</span><span class="syntaxdefault">curCookie&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">name&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxstring">"="&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">escape</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">value</span><span class="syntaxkeyword">)&nbsp;+<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((</span><span class="syntaxdefault">expires</span><span class="syntaxkeyword">)&nbsp;?&nbsp;</span><span class="syntaxstring">";&nbsp;expires="&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">expires</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">toGMTString</span><span class="syntaxkeyword">()&nbsp;:&nbsp;</span><span class="syntaxstring">""</span><span class="syntaxkeyword">)&nbsp;+<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)&nbsp;?&nbsp;</span><span class="syntaxstring">";&nbsp;path="&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">path&nbsp;</span><span class="syntaxkeyword">:&nbsp;</span><span class="syntaxstring">""</span><span class="syntaxkeyword">)&nbsp;+<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((</span><span class="syntaxdefault">domain</span><span class="syntaxkeyword">)&nbsp;?&nbsp;</span><span class="syntaxstring">";&nbsp;domain="&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">domain&nbsp;</span><span class="syntaxkeyword">:&nbsp;</span><span class="syntaxstring">""</span><span class="syntaxkeyword">)&nbsp;+<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((</span><span class="syntaxdefault">secure</span><span class="syntaxkeyword">)&nbsp;?&nbsp;</span><span class="syntaxstring">";&nbsp;secure"&nbsp;</span><span class="syntaxkeyword">:&nbsp;</span><span class="syntaxstring">""</span><span class="syntaxkeyword">);<br />&nbsp;&nbsp;</span><span class="syntaxdefault">document</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">cookie&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">curCookie</span><span class="syntaxkeyword">;<br />}<br /><br /><br /></span><span class="syntaxcomment">/*<br />&nbsp;&nbsp;name&nbsp;-&nbsp;name&nbsp;of&nbsp;the&nbsp;desired&nbsp;cookie<br />&nbsp;&nbsp;return&nbsp;string&nbsp;containing&nbsp;value&nbsp;of&nbsp;specified&nbsp;cookie&nbsp;or&nbsp;null<br />&nbsp;&nbsp;if&nbsp;cookie&nbsp;does&nbsp;not&nbsp;exist<br />*/<br /><br /></span><span class="syntaxkeyword">function&nbsp;</span><span class="syntaxdefault">getCookie</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">name</span><span class="syntaxkeyword">)&nbsp;{<br />&nbsp;&nbsp;var&nbsp;</span><span class="syntaxdefault">dc&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">document</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">cookie</span><span class="syntaxkeyword">;<br />&nbsp;&nbsp;var&nbsp;</span><span class="syntaxdefault">prefix&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">name&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxstring">"="</span><span class="syntaxkeyword">;<br />&nbsp;&nbsp;var&nbsp;</span><span class="syntaxdefault">begin&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">dc</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">indexOf</span><span class="syntaxkeyword">(</span><span class="syntaxstring">";&nbsp;"&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">prefix</span><span class="syntaxkeyword">);<br />&nbsp;&nbsp;if&nbsp;(</span><span class="syntaxdefault">begin&nbsp;</span><span class="syntaxkeyword">==&nbsp;-</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">begin&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">dc</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">indexOf</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">prefix</span><span class="syntaxkeyword">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span class="syntaxdefault">begin&nbsp;</span><span class="syntaxkeyword">!=&nbsp;</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">)&nbsp;return&nbsp;</span><span class="syntaxdefault">null</span><span class="syntaxkeyword">;<br />&nbsp;&nbsp;}&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">begin&nbsp;</span><span class="syntaxkeyword">+=&nbsp;</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">;<br />&nbsp;&nbsp;var&nbsp;</span><span class="syntaxdefault">end&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">document</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">cookie</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">indexOf</span><span class="syntaxkeyword">(</span><span class="syntaxstring">";"</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">begin</span><span class="syntaxkeyword">);<br />&nbsp;&nbsp;if&nbsp;(</span><span class="syntaxdefault">end&nbsp;</span><span class="syntaxkeyword">==&nbsp;-</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">end&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">dc</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">;<br />&nbsp;&nbsp;return&nbsp;</span><span class="syntaxdefault">unescape</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">dc</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">substring</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">begin&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">prefix</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">end</span><span class="syntaxkeyword">));<br />}<br /><br /><br /></span><span class="syntaxcomment">/*<br />&nbsp;&nbsp;&nbsp;name&nbsp;-&nbsp;name&nbsp;of&nbsp;the&nbsp;cookie<br />&nbsp;&nbsp;&nbsp;[path]&nbsp;-&nbsp;path&nbsp;of&nbsp;the&nbsp;cookie&nbsp;(must&nbsp;be&nbsp;same&nbsp;as&nbsp;path&nbsp;used&nbsp;to&nbsp;create&nbsp;cookie)<br />&nbsp;&nbsp;&nbsp;[domain]&nbsp;-&nbsp;domain&nbsp;of&nbsp;the&nbsp;cookie&nbsp;(must&nbsp;be&nbsp;same&nbsp;as&nbsp;domain&nbsp;used&nbsp;to<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;create&nbsp;cookie)<br />&nbsp;&nbsp;&nbsp;path&nbsp;and&nbsp;domain&nbsp;default&nbsp;if&nbsp;assigned&nbsp;null&nbsp;or&nbsp;omitted&nbsp;if&nbsp;no&nbsp;explicit<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;argument&nbsp;proceeds<br />*/<br /><br /></span><span class="syntaxkeyword">function&nbsp;</span><span class="syntaxdefault">deleteCookie</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">name</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">domain</span><span class="syntaxkeyword">)&nbsp;{<br />&nbsp;&nbsp;if&nbsp;(</span><span class="syntaxdefault">getCookie</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">name</span><span class="syntaxkeyword">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">document</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">cookie&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">name&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxstring">"="&nbsp;</span><span class="syntaxkeyword">+<br />&nbsp;&nbsp;&nbsp;&nbsp;((</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)&nbsp;?&nbsp;</span><span class="syntaxstring">";&nbsp;path="&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">path&nbsp;</span><span class="syntaxkeyword">:&nbsp;</span><span class="syntaxstring">""</span><span class="syntaxkeyword">)&nbsp;+<br />&nbsp;&nbsp;&nbsp;&nbsp;((</span><span class="syntaxdefault">domain</span><span class="syntaxkeyword">)&nbsp;?&nbsp;</span><span class="syntaxstring">";&nbsp;domain="&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">domain&nbsp;</span><span class="syntaxkeyword">:&nbsp;</span><span class="syntaxstring">""</span><span class="syntaxkeyword">)&nbsp;+<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxstring">";&nbsp;expires=Thu,&nbsp;01-Jan-70&nbsp;00:00:01&nbsp;GMT"</span><span class="syntaxkeyword">;<br />&nbsp;&nbsp;}<br />}<br /><br /></span><span class="syntaxcomment">//&nbsp;date&nbsp;-&nbsp;any&nbsp;instance&nbsp;of&nbsp;the&nbsp;Date&nbsp;object<br />//&nbsp;*&nbsp;hand&nbsp;all&nbsp;instances&nbsp;of&nbsp;the&nbsp;Date&nbsp;object&nbsp;to&nbsp;this&nbsp;function&nbsp;for&nbsp;"repairs"<br /><br /></span><span class="syntaxkeyword">function&nbsp;</span><span class="syntaxdefault">fixDate</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">date</span><span class="syntaxkeyword">)&nbsp;{<br />&nbsp;&nbsp;var&nbsp;</span><span class="syntaxdefault">base&nbsp;</span><span class="syntaxkeyword">=&nbsp;new&nbsp;</span><span class="syntaxdefault">Date</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">);<br />&nbsp;&nbsp;var&nbsp;</span><span class="syntaxdefault">skew&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">base</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">getTime</span><span class="syntaxkeyword">();<br />&nbsp;&nbsp;if&nbsp;(</span><span class="syntaxdefault">skew&nbsp;</span><span class="syntaxkeyword">>&nbsp;</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">date</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">setTime</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">date</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">getTime</span><span class="syntaxkeyword">()&nbsp;-&nbsp;</span><span class="syntaxdefault">skew</span><span class="syntaxkeyword">);<br />}<br /><br /></span><span class="syntaxcomment">//&nbsp;-->&nbsp;</span><span class="syntaxdefault"></span>

tražim po netu kako postaviti cookie bez vremenskog ograničenja.

kaže internet da ako je time set 0, cookie se briše kod zatvaranja browsera.
to mi ne treba.
onda kaže da je jedino rješenje da mi se cookie ne briše je postaviti vrijeme isteka cookija negdje daleko u budućnost :ludjak: . to mi se baš ne sviđa. jel ima neko rješenje kao npr. time = infinity ili nešto? :krele:

Ups! mislim da je ovo post za php a ne javascript :uaa:

[quote=“nibuster”]tražim po netu kako postaviti cookie bez vremenskog ograničenja.

kaže internet da ako je time set 0, cookie se briše kod zatvaranja browsera.
to mi ne treba.
onda kaže da je jedino rješenje da mi se cookie ne briše je postaviti vrijeme isteka cookija negdje daleko u budućnost :ludjak: . to mi se baš ne sviđa. jel ima neko rješenje kao npr. time = infinity ili nešto? :krele:[/quote]

Mislim da ne postoji drugaciji nacin. Postavis kuki na 3583. godinu i rjesio si problem vremenskog ogranicenja. Ako ne vjerujes, probaj. :smiley:


Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Webmaster.Ninja